我想输出数据库的一行作为另一行的链接,但失败了

deikduxw  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(232)

我想把它们输出到一个表中
谢谢如果有人能帮我我正在学习php。
我正在学习做一个链接管理,它使用php和mysql。如果有人能推荐源代码,我将非常感谢。

<?php 
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("abc", $con);

$result = mysql_query("SELECT * FROM links");

    while($row = mysql_fetch_array($result))
    {
    echo "<tr>";
    echo "<td><a href='{$row[Link]}'>{$row[Name]}</a></td>" ;
    echo "</tr>";
    }

?>
qoefvg9y

qoefvg9y1#

你的引号到处都是,双引号将用于开始和停止字符串如果你用他们开始,但你也有引号轮 <a> 标记时,如果数组中有双引号,也可以省略数组索引周围的引号,因此可以使用。。。

echo "<td><a href='{$row[Link]}'>{$row[Name]}</a></td>" ;

或者,如果你想坚持使用双引号,你需要摆脱内在的双引号。。。

echo "<td><a href=\"{$row['Link']}\">{$row['Name']}</a></td>" ;

相关问题