-1
我对PHP相对较新。我通过数据库挖掘了几个关卡,并且遇到了困难。我无法弄清楚为什么我只需要检索一个重复的记录时,应该只有5个不同的记录。我的代码如下...在PHP深入重复值
<?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>';
?>
任何帮助,将不胜感激
感谢
当您直接针对数据库运行时,您的查询是否返回预期结果? –
要小心,您的代码可以注入恶意SQL –
您所说的是,您检索5个记录,但是取代5个不同的记录,而是同一个记录? –