显示“未定义变量:display1”。我能够显示while循环。问题是 $display1 在 while 循环中定义,它必须在其中,因为有 $i 增量。
//SQL for display category name
$query1="SELECT cat_name FROM restaurant_category WHERE rest_id={$display}";
$result1=mysql_query($query1);
$rowNum1=mysql_num_rows($result1);
//SQL for display dish information of each category
$query3="SELECT cat_id FROM restaurant_category WHERE cat_name={$display1}";
$result3=mysql_query($query3);
$display3=mysql_query($result3);
$query2="SELECT dish_name, dish_description, dish_price FROM dish WHERE cat_id={$display3}";
$result2=mysql_query($query2);
$rowNum2=mysql_num_rows($result2);
$data=mysql_fetch_row($result2);
while($i<$rowNum1)
{
$display1=mysql_result($result1,$i,"cat_name");
//display category name
while($j<$rowNum2)
{//display dish information}
}