我是php和sqlite的新手。我有一个sqlite数据库,其中包含以下字段:
name
voterID,
memberID,
constituency,
electoralarea,
branchcode
我能够以html显示输出。我现在要做的是为内容(树)创建一个目录,并按照以下顺序进行:
选区, electoralarea, branchcode,
分支代码应包含内容的pdf文件。这是name,voterID,memberID,表格格式的照片
这就是我的代码的样子:
<?php
class MyDB extends SQLite3
{
function __construct()
{
$this->open('C:\xampp\htdocs\NDC\database\central.NDC');
}
}
$db = new MyDB();
if(!$db){
echo $db->lastErrorMsg();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SUPPLEMENTARY LIST</title>
</style
</head>
<body>
<?php
$sql =<<<EOF
select v.pollingName,v.name,v.memberID,p.foto,v.voterID,v.branchCode,v.electoralName ,v.constituency
from voter v,photo p
where v.voterID = p.voterID and v.branchCode IN ('B152704') order by v.name,v.voterID;
group by v.branchcode
EOF;
echo "<table border='1' align ='center' cellpadding ='1' cellspacing ='0' width=800 height=100>
<tr>
<th><font face='Arial' size = 2.5>#</font></th>
<th><font face='Arial' size = 2.5>FULLNAME</font></th>
<th><font face='Arial' size = 2.5>MEMBERID</font></th>
<th><font face='Arial' size = 2.5>VOTERID</font></th>
<th><font face='Arial' size = 2.5>BRANCHCODE</font></th>
<th><font face='Arial' size = 2.5>PICTURE</font></th>
<th><font face='Arial' size = 2.5>Status (Tick)</font></th>
</tr>";
$counter = 0;
/*$image = imagecreatefromstring($blob);
ob_start(); //You could also just output the $image via header() and bypass this buffer capture.
imagejpeg($image, null, 80)
$foto = ob_get_contents();
ob_end_clean();*/
$ret = $db->query($sql);
$i = 0;
echo '<tbody><tr>';
while($row = $ret->fetchArray(SQLITE3_ASSOC) ){
if ($i > 1 && $i % 10 == 0)
echo '</tr><tr class="breakAfter">';
else if ($i)
echo '</tr><tr>';
++$i;
$counter++;
//echo "<center><strong>".$row ['electoralName'];
// echo "<font face='Arial' size = 2.5 >" . wordwrap($row['pollingName'],-1,"<br />\n"). "</font>";
echo "<tr>";
echo "<td align = 'center'><font face='Arial' size = 2.5 ><strong>" . $counter . "</strong></font></td>";
echo "<td align = 'center'><font face='Arial' size = 2.5 >" . wordwrap($row['name'],40, "<br />\n") . "</font></td>";
echo "<td align = 'center'><font face='Arial' size = 2.5 >" . $row['memberID'] . "</font></td>";
echo "<td align = 'center'><font face='Arial' size = 2.5 >" . $row['voterID'] . "</font></td>";
echo "<td align = 'center'><font face='Arial' size = 2.5 >" . $row['branchCode'] . "</font></td>";
//echo "<td align = 'center'><font face='verdana'>" . $row[''] . "</font> </td>";
echo "<td align = 'center'>" . '<img src="data:image/jpg;base64,' . base64_encode($row['foto']).'" width="100" height="115"/>' . "</td>";
//'<img src="data:image/jpeg;base64,' . base64_encode($row2['image']) . '" width="290" height="290">'
echo "<td align = 'center'><strong>" . '['.' '.' '.' '.']'. "</strong></td>";
//echo "<p style=\"page-break-after: always\">\n";
echo "</tr>";
//'<img src="data:image/jpeg;base64,'.base64_encode( $result['image'] ).'"/>'
}
//echo "Operation done successfully\n";
$db->close();
?>
</p>
</body>
</html>