在我的表中将数据库中的路径显示为链接


Displaying a path from the database as a link, in my table

我正试图在使用数据库中存储的路径创建的报告表中显示一个链接,但我很难弄清楚如何将其正确显示为指向图像的链接。因此,与显示不同图像的表格不同,我只需要一个通用链接,上面写着"image link"或其他什么,并通过href将它们带到图像src,而不是显示图像。

以下是html表中的数据循环方式:

$i=0;
while ($i < $num) {
$date=mysql_result($result,$i,"datetime");
$firstname=mysql_result($result,$i,"first");
$lastname=mysql_result($result,$i,"last");
$message=mysql_result($result,$i,"message");
$image=mysql_result($result,$i,"imagepath");
echo '<tr>';
echo '<td>' . $date . '</td>';
echo '<td>' . $firstname . '</td>';
echo '<td>' . $lastname . '</td>';
echo '<td>' . $message . '</td>';
echo '<td>' . $image . '</td>';
echo '</tr>';
$i++;
}

这是上传位置和图像路径存储变量

//Where the file will be placed
$target_path = "uploads/";
// Add the original filename to target path
$path= $target_path . basename($image);

显示数据的报告页面也位于uploads文件夹的根目录下。我尝试过将image变量(在循环中)添加到通用src链接中,但它什么也不显示,或者破坏了表并生成语法错误。这把我难住了。

尝试:<a href="<?php echo $target_path; ?><?php echo $image ?>">Image</a>,如果我是对的,它会起作用。