想要在php中检索数据 [英] want to retrieve the data in php
本文介绍了想要在php中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在建立一个餐厅的网站.在数据库中,我创建了两个表
I am making a website of a resturant. in database I have created two tables
1-food(id,food_name,cat_id(F.K),)
2-category(cat_id,cat_name)
我想在导航栏中显示类别,然后单击类别就必须显示该类别下受人尊敬的食物.
示例我的表中有以下条目
I want to display the category in navigation bar and on clicking the category it has to show the respected food that comes under the category.
example I have the following entries in my table
food_name=Zinger Burger,Chicken Burger,Sea Food
cat_name=FastFood,Fish
如何在菜单栏上将类别显示为超链接,并在单击时显示数据库中的食物,在单击快餐时它将显示生姜和鸡肉汉堡.
以下是我到目前为止已完成的工作
how can I show the category on menu bar as a hyperlink and on clicking the shows the food from database that is onclicking the fastfood it shows the zinger and chicken burger.
below is my work which I have done so far
?php
$query="Select * from category";
$result=mysql_query($query,$connection);
while($category=mysql_fetch_array($result))
{?>
<ul>
<li>
<?php $category["cat_name"]; <br mode="hold" /?>
echo "<a href="\"show.php\""> ".$category['cat_name'] ." </a>";
}?>
</li>
</ul>
<?php <br mode="hold" /?>
//$food="Select * from food where cat_id={$category["cat_id"]} ";
$query = "SELECT * ";
$query .= "FROM subjects ";
$query .= "WHERE cat_id=" . $category["cat_id"] ." ";
$result1=mysql_query($query,$connection);
while($foodname=mysql_fetch_array($result1))
{
echo"<li> {$foodname["food_name"]}</li>";
}
echo "";
?>
推荐答案
query = " 从类别中选择* ;
query="Select * from category";
result = mysql_query(
result=mysql_query(
query,
这篇关于想要在php中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文