我在数据库中有两个表,sight_country
和sightseeing
。我将sight_country
表中的国家/地区字段的ID插入表sightseeing
的s_country
字段。在php中,我在CSS下拉菜单栏中显示来自sight_country
的国家/地区字段值。如何在php中显示两个表中的数据
代码
<li class="menu-item-has-children"><a href="#">Sightseeing</a>
<ul class="sub-menu">
<?php
$qry_st = "select * from `sight_country` limit 5";
$rec_st = mysql_query($qry_st);
if(mysql_num_rows($rec_st) > 0)
{
while($res_st = mysql_fetch_array($rec_st))
{
echo "<li><a href='sightseeing.php?id=$res_st[id]'>".$res_st['country']."</a></li>";
}
}
?>
</ul>
</li>
当点击县城值,那么我表示从PHP页面表观光游览的所有数据的链接。
代码
$sql = "select * from `sightseeing` where `s_country` ='$id'";
$res = mysql_query($sql);
$rec = mysql_fetch_array($res);
该国可能有两个或多个相关观光数据,所以我从观光表在我的PHP页面侧边栏菜单显示观光冠军。
代码
<ul class="st_lnks">
<?php
$qry_st = "select * from `sightseeing` where s_country = '$id'";
$rec_st = mysql_query($qry_st);
if(mysql_num_rows($rec_st) > 0)
{
while($res_st = mysql_fetch_array($rec_st))
{
echo "<li><a href='sightseeing.php?id=$res_st[s_country]'>".$res_st['stitle']."</a></li>";
}
}
?>
</ul>
当我点击stitle我想表明它是在同一个页面相关的观光数据的链接。如何做到这一点?
'相关观光数据'这是什么? –
什么是错误? –