我已经使用此代码显示从数据库上传的文件,首先用户需要选择一个文件名,然后他可以使用“下载”选项查看文件详细信息(名称 + 大小 + mime ..),问题是这个页面是重复文件详细信息 4 次,名称、大小和下载全部重复,有什么问题?
这是我的代码
$sql = "SELECT r.id, r.name , r.mime, r.size, r.date , s.email
from project_report AS r
JOIN evaluator_supervisor AS e
JOIN student AS s
WHERE (s.PID = $PID AND e.EID1 = '$id' AND s.SID=r.SID) OR (s.PID = $PID AND e.EID2 = '$id' AND s.SID=r.SID) ";
$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>"Sorry, No files uploaded"</p>';
}
else {
// Print the top of a table
echo '<center>';
echo '<table width="90%">
<tr>
<td><b>Name</b></td>
<td><b>Mime</b></td>
<td><b>Size (bytes)</b></td>
<td><b>Date</b></td>
<td><b> </b></td>
<td><b>Feedback</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['date']}</td>
<td><a href='Download.php?id={$row['id']}'>Download</a></td>
<td><a href='messege2.php?id={$row['email']}'><img src='mail2.gif'/></a></td>
</tr>";
}
// Close table
echo '</table>';
echo '</center>';
}