我在数据库中有一个电子书表格,其中定义了pdf的路径。我想要的是,当用户点击下载按钮时,pdf下载。但是下载按钮不起作用我就是这样也没有从Php.Please帮助中得到任何错误!谢谢。
代码:
<div id="data">
<?php
if (isset($_POST['submit'])) {
$title = $_POST['title'];
$name = $_POST['name'];
$count = 1;
$query = "SELECT * FROM ebooks WHERE $title LIKE '%".$name."%'";
$display = $obj->run_query($query);
?>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr align="center">
<td>No.</td>
<td>Title</td>
<td>Author</td>
<td>Publication</td>
<td>Status</td>
</tr>
</thead>
<tbody>
<?php
foreach ($display as $key) { ?>
<tr align="center">
<td><?php echo $count++;?></td>
<td><?php echo $key['ebook_title'];?></td>
<td><?php echo $key['ebook_author'];?></td>
<td><?php echo $key['ebook_publication'];?></td>
<td><a style="color:white;" href="/admin/ebooks/<?php echo $key['ebook_url'];?>" class="btn btn-round btn-primary">Download</a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php } ?>
</div>
</div>
答案 0 :(得分:1)
你必须在结束锚标记之前添加下载试试这个:
<a style="color:white;" href="/admin/ebooks/<?php echo $key['ebook_url'];?>" class="btn btn-round btn-primary" download>Download</a>