将链接转换为超文本或文本

时间:2014-12-14 17:56:16

标签: php html mysql

我努力将从数据库转换为超文本的链接。

想象一下像http://example.com/file.txt

这样的链接字符串

如何更改echo语句以在下载链接上显示id文件名?

<?php
$con=mysqli_connect("example.com","username","pass","example.com");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM moviebase");

echo "<table border='1'>
<tr>
<th> ID </th>
<th> File Name </th>
<th> Link 1 </th>
<th> Link 2 </th>
</tr>";

while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['ID'] . "</td>";
echo "<td>" . $row['filename'] . "</td>";
echo "<td>" . $row['link1'] . "</td>";
echo "<td>" . $row['link2'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysqli_close($con);
?>    

2 个答案:

答案 0 :(得分:1)

echo "<td><a href='" . $row['link1'] . "'>download</a></td>";

答案 1 :(得分:1)

echo "<td><a href=".$row['link1'].">".$row['link1']."</a></td>";
echo "<td><a href=".$row['link2'].">".$row['link2']."</a></td>";