-3
내가 rest_categories, rest_type 및 rest_dish CAT_ID를 저장하는 3 개 테이블이 또한 ty_id & rest_dish이 rest_dish에서 FK이다 rest_type에 FK이다. PHP MySQL의 : 레스토랑
나는 그것이 첫 번째 기록
에게 표시 while 루프를 사용하여 표시하려고
. CODE : <?php
$cat_ct = mysql_query("SELECT COUNT(cat_name) FROM rest_categories;");
$cat = mysql_query("SELECT * FROM rest_categories");
while ($row = mysql_fetch_array($cat))
{
$cat_id = $row["cat_id"];
$cat_name = $row["cat_name"];
?>
<h2><?php echo "$cat_name"; ?></h2>
<?php
$ty_ct = mysql_query("SELECT COUNT(ty_name) FROM rest_type;");
$cat = mysql_query("SELECT * FROM rest_type where cat_id='$cat_id'");
while ($row = mysql_fetch_array($cat))
{
$ty_id = $row["ty_id"];
$ty_name = $row["ty_name"];
?>
<h3> <?php echo "$ty_name"; ?> </h3>
<br>
<?php
$dish_ct = mysql_query("SELECT COUNT(dish_name) FROM rest_dish;");
$cat = mysql_query("SELECT * FROM rest_dish where cat_id='$cat_id' and ty_id='$ty_id'");
while ($row = mysql_fetch_array($cat))
{
$dish_id = $row["dish_id"];
$dish_price = $row["online_price"];
$dish_name = $row["dish_name"];
?>
<div class="wrapper pad_bot1">
<table>
<tr>
<td>
<?php echo "$dish_name"; ?> </td>
<td>           <?php echo "$dish_price"; ?> </td>
</tr>
</div>
</table>
<?php }
}
} ?>
</section>
</div>
</article>
</div>
감사합니다. 효과가있는 – user3770087