好的,这是我的代码:
$select_status = 0;
$select_status = "<select name='status'>\n";
$select_status .= "<option value=''>SELECT ONE</option>\n";
$sdataset = mysql_query("SELECT id, name FROM phponly_category") or die(mysql_error());
while($srow=mysql_fetch_assoc($sdataset)) {
echo implode(", ", $srow);
echo "<br />";
$select_status .= "<option value='".$srow['name']."'";
$select_status .= ">".$srow['name']."</option>\n";
} // end while loop
echo "out of the loop";
$select_status .= "</select>\n";
// now insert the <select> list control into the page
echo $select_status;
代码工作正常,直到最后一行中断。我无法打印echo $select_status 。我试图通过打印每一行来查看 SQL 查询结果发生了什么,但那里的一切看起来都很好。出于某种原因,在最后一行,while 循环中断,甚至while 循环之后的代码也没有被执行。