在我的代码中,它应该为通往相应页面的每个ID创建一个链接,但它会导致该页面?ID = Array而不是?ID = ID

这是我的代码,您可以在这里查看: http : //pirates-online-rewrite.com/testblog.php

<?php
include "connect.php";
$ids = mysql_query("SELECT ID FROM Blogs ORDER BY ID DESC LIMIT 10");
while($id=mysql_fetch_assoc($ids)){
echo "<a href='http://www.pirates-online-rewritten.com/blog.php?ID=", $id, "'>Test</a><br />";
}
?>

===============>>#1 票数:2

应该是$id['ID']而不是$id

像这样..

<?php
include "connect.php";
$ids = mysql_query("SELECT ID FROM Blogs ORDER BY ID DESC LIMIT 10");
while($id=mysql_fetch_array($ids)){ //<--- Changed to fetch_array
    echo "<a href='http://www.pirates-online-rewritten.com/blog.php?ID=", $id['ID'], "'>Test</a><br />";
}

PHP 5.5.0不推荐使用( mysql_* )扩展名,以后将删除该扩展名。 相反,应使用MySQLiPDO_MySQL扩展的Prepared Statements来抵御SQL Injection攻击!

  ask by Sam translate from so

未解决问题?本站智能推荐: