我对 PHP 比较陌生。我已经通过数据库钻了几个级别,我遇到了一个障碍。我不知道为什么我只检索一个重复的记录,而应该只有 5 个不同的记录。我的代码在下面...
<?php
$sections = $_GET['rid'];
// Connects to Database
mysql_connect("localhost", "root") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
$data = mysql_query("SELECT question_keywords.rfp_id, question_keywords.section_id, section_name FROM rfp, question_keywords, section WHERE question_keywords.rfp_id = rfp.rfp_id AND section.section_id = question_keywords.section_id AND section.section_id = '$sections'")
or die(mysql_error());
echo "<table border=0 cellpadding=15>";
echo "<tr align = center bgcolor=white>
<td><b>Section ID</b></td><td><b>Section Name</b></td>" ;
while($row = mysql_fetch_array($data)){
$sid = $row['section_id']; //if you have the column names, replace 0 with 'column_name'
$sname = $row['section_name'];
# $status = $row['status'];
# inserts value into table as a hyperlink
echo "<tr align = center bgcolor=white><td>$sid</td><td><a href=view_section_detail.php?sid=$sid>$sname</a></td>";
}
# displays table
print '</table>';
?>
任何帮助,将不胜感激
谢谢