我想用PHP创建一个链接,从我的MySQL数据库表中打开一个PDF文件。 PDF文件已存储在Sql表中我只是不确定如何用锚标记打开它。如何使用锚标记打开存储在MySQL表中的PDF文件
该PDF被称为“a26ea542-b307-4cd6-9f62-7ba04831a0f1.pdf”。
这是我的PHP页面代码:
<?php
// Connect to the database
$dbLink = new mysqli('aaa', 'aaa', 'aaa', 'aaa');
if(mysqli_connect_errno()) {
die("MySQL connection failed: ". mysqli_connect_error());
}
// Query for a list of all existing files
$sql = 'SELECT `id`, `name`, `mime`, `size`, `created` FROM `file`';
$result = $dbLink->query($sql);
// Check if it was successfull
if($result) {
// Make sure there are some files in there
if($result->num_rows == 0) {
echo '<p>There are no files in the database</p>';
}
else {
// Print the top of a table
echo '<table width="100%">
<tr>
<td><b>Name</b></td>
<td><b>Mime</b></td>
<td><b>Size (bytes)</b></td>
<td><b>Created</b></td>
<td><b> </b></td>
</tr>';
// Print each file
while($row = $result->fetch_assoc()) {
echo "
<tr>
<td>{$row['name']}</td>
<td>{$row['mime']}</td>
<td>{$row['size']}</td>
<td>{$row['created']}</td>
<td><a href='{$row['name']}'>Open</a></td>
</tr>";
}
// Close table
echo '</table>';
}
// Free the result
$result->free();
}
else
{
echo 'Error! SQL query failed:';
echo "<pre>{$dbLink->error}</pre>";
}
// Close the mysql connection
$dbLink->close();
?>
谢谢,任何帮助。我很欣赏任何反馈。
PDF存储在MySQL数据库中,而不是存储在我的FTP服务器中。 – Kelsey
@迈克尔我知道这一点! – SteAp
我的PHPmyAdmin网址是cp.freehostia.com,我用它来取代http://myServ.com? – Kelsey