我正在尝试在选择和选项字段
中显示数据库字段<?php
$con = mysql_connect("localhost","cl49-XXX","XXX");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("cl49-XXX", $con)or die( "Unable to select database");
$result=mysql_query("SELECT * FROM categories")or die('You need enter a catagory ' );
echo "<tr>"; // first row beginning
for ($i = 1; $i <= mysql_num_rows($result); $i++){
$row = mysql_fetch_array($result);
$id = $row['id'];
$category= $row['category'];
echo "<option>$category'
";
if ($i % 4 == 0) {
echo "</option><option>"; // it's time no move to next row
}
}
echo ""; // last row ending
?>
为什么我没有显示任何字段?
答案 0 :(得分:1)
echo "</option><option>";
为什么你有2个<option>
标签?仅使用结束标记
echo `</option>`