我的表格citizens
包含字段id
,title
和link
。如果我使用这些代码,它将显示id的所有内容,我需要的是当我点击第一个id id时它应该显示该行的内容。我试图删除循环并将数组更改为assoc,但是当我选择第二个id时,它将始终显示1个id。
mysql_select_db("do",$con1);
$sql = "SELECT * FROM citizens ORDER BY id DESC";
$myData = mysql_query($sql,$con1);
while($record = mysql_fetch_array($myData)){
echo $record['div'];
答案 0 :(得分:-1)
如果您想从ID为1的数据库中获取单个记录,请尝试以下操作:
$myID = 1;
mysql_select_db("do",$con1);
$sql = "SELECT * FROM citizens WHERE id = $myID ORDER BY id DESC";
$myData = mysql_query($sql, $con1);
$record = mysql_fetch_row($myData);
echo $record['div'];