-1

我对 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>';

 ?>

任何帮助,将不胜感激

谢谢

4

1 回答 1

0

我猜您只是忘记添加两个</tr>s 如果您查看 HTML-Output 它应该在那里。尝试 :

echo "<tr align = center bgcolor=white>
<td><b>Section ID</b></td><td><b>Section Name</b></td></tr>" ; 

和:

echo '</tr></table>';

正如已经说明的评论,尝试在 sql 命令(或 phpmyadmin)中针对数据库查询您的命令。

于 2012-09-11T16:03:48.343 回答