将获取的数组放入<a href=""> value in PHP</a>

时间:2014-05-17 12:40:14

标签: php echo

我有一个SQL查询语句,它将返回一组特定的结果。如ID,姓名,价格。对于那件事我没有任何疑问。

但是我试图在echo循环中添加一个链接并将ID设置为值,以便我可以将其发布到另一个页面。那可能吗?

    while ($row = mysql_fetch_array($result)) {
   echo
   "".$row{'Url'}."<br>"; 
   echo 
   "Name:".$row{'Name'}."<br>";
   echo
   "Price: $ ".$row{'Price'}."<br>";
   echo
   '<div class = "qwerty"  data-countdown= '.$row{'Time'}.'></div>';
   echo
   "Location:".$row{'Location'}."<br>";
   echo
   "Description:".$row{'Description'}."<br>";
echo   ''.$row{'ID'}.'';


echo '<a href="" onclick="jsScript()">Show Comments</a>
    <form id="displayComments" style="display:none" target="jsScript()" method="post">
    <input type="hidden" name="run" value=".$row{'ID'}." />
    </form>';

1 个答案:

答案 0 :(得分:1)

你错过了报价。 value="'.$row['ID'].'"

echo '<a href="" onclick="jsScript()">Show Comments</a> <form id="displayComments" style="display:none" target="jsScript()" method="post"> <input type="hidden" name="run" value="'.$row['ID'].'" /> </form>';

php数组使用[]

http://ua2.php.net/manual/en/language.types.array.php