如何使表字段作为链接返回(通过简单的 echo 命令)


How to Make a table field return as a link (from a simple echo command)

我已经尝试了几个小时,以弄清楚如何通过 PHP echo() 将链接放入以下文本输出中。 我基本上想让我从事件表中提取的标题字段(如下面代码中的 #4 所示)作为链接返回浏览器,而不仅仅是文本......

带回事件标题的原始代码:

<?php
// 3. Perform database Query to bring list of events
$result = mysql_query("SELECT * FROM events", $connection);
if (!$result) {
    die("Database query failed: " . mysql_error());
}
// 4. Use returned Data
while ($row = mysql_fetch_array($result)) {
    echo $row ["eventtitle"]."<br/>".$row["eventdesc"]."<br/>";
}
?>

我将如何让该$row["eventtitle"]作为链接显示在浏览器中?假设链接是否只是"事件配置文件.php"。 这可能是一个简单的解决方法,但是我在尝试<a href>不同的事情时遇到了一百万个错误。

<?php
$result = mysql_query("SELECT * FROM events", $connection);
if (!$result) {
 die("Database query failed: " . mysql_error());
}
while ($row = mysql_fetch_array($result)) {
 echo "<a href='"eventprofile.php'">".$row["eventtitle"]."</a><br/>".$row["eventdesc"]."<br/>";
}
?>

它添加一个锚标签!!

echo "<a href='"" . $row['eventtitle'] . "'">" . $row['eventtitle'] . '</a>' . "<br />" .$row["eventdesc"]."<br/>";

仅此而已。