我这里有一个免费的错误如何通过PHP从数据库中的所有数据显示HTML表格上的代码,但不是唯一的显示字符和数字,我也想显示BLOB数据,比如PDF,图片,TXT等等,你们可以请帮助我怎么了,顺便说一句即时通讯新的PHP和mysqli的,$行[10],是我所到BLOB数据类型的字段提前家伙,谢谢,我爱你们!
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "recordmain_db" ;
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($conn,"SELECT * FROM recordmain_table");
echo "<center><table id=myTable table border=8 cellspacing=1
cellpadding=5>";
echo "<tr class='header'>
<th>Doc Type</th>
<th>Doc Date</th>
<th>Date Sent</th>
<th>Medium of Transaction</th>
<th>Description</th>
<th>Receiver</th>
<th>Address</th>
<th>Contact</th>
<th>Attachment</th>
<th>File</th>
</tr>";
?>
<?php
while($row = mysqli_fetch_array($result))
{
echo
"<tr>
<td>" . $row[1] . "</td>
<td> " . $row[2] . "</td>
<td>" . $row[3] . "</td>
<td>" . $row[4] . "</td>
<td>" . $row[5] . "</td>
<td>" . $row[6] . "</td>
<td>" . $row[7] . "</td>
<td>" . $row[8] . "</td>
<td>" . $row[9] . "</td>
<td>" . $row[10] . "</td>
</tr>";
}
echo "</table></center>";
mysqli_close($conn);
?>
你可以使用base64_encode()
显示BLOB数据为PDF格式:
"<object data=\"data:application/pdf;base64," . base64_encode($row[10]) . " type=\"application/pdf\" ></object>"