select * from 酒店表 as a inner join 房型表 as b on a.hid = b.hid这个是SQL语句!PHP的语法我还没研究那!呵呵
解决方案 »
- 投票的数据库设计方法
- PHP如何获取系统NTP的ip还有系统的DateFromat,TimeFromat,判定系统的NTP是否有可能???
- 用MAIL函数为什么收到这样的邮件 急在线等
- PHP+MySQL,多条Insert为什么不工作?
- 怎样简单实现使用mail()函数一次发送text、html两种格式的邮件?即一封邮件具有text、html两种格式?
- 什么样的开发经验说得上是开发项目的经验?[PHP编程]
- 求一函数
- 如何防止盗连
- 每个楼层下面评论------Ajax分页
- php telnet 问题,很慢才能取得返回值。
- php连接微软的ms sql2000后,如何获得id最大的一条记录?
- 如何将几个数组写入php
//开始搜索
$sql = "SELECT hotelb.*,roomb.* FROM ".tname('hotelb')." hotelb left join ".tname('roomb')." roomb on hotelb.id =roomb.c_id WHERE hotelb.city LIKE '%$gets[txtCity]%' and hotelb.c_name LIKE '%$gets[txtHotelName]%' and hotelb.type LIKE '%$gets[rdoHotelType]%' and hotelb.level LIKE '%$gets[chkStarA]%' and hotelb.jddz LIKE '%$gets[address]%' and roomb.etprice >= $gets[txtPriceLow] and roomb.etprice<= $gets[txtPriceHigh] ";
$query = $_SGLOBAL['db']->query($sql.' LIMIT 0, 100');//最多100条
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
$list[] = $value;
}这是我写的,不知道前台怎么显示
hid name city info rid
1 首都大酒店 北京 位于北京 1
2 富丽华大酒店 大连 位于大连 1
3 皇姑大酒店 沈阳 位于沈阳 2表二(房型表)字段:
rid type info price
1 豪华房间 非常豪华 255
2 普通房价 一般 100
<?php
$site="localhost";
$name="phpdb";
$root="root";
$ps="1234";
$conn=mysql_connect($site,$root,$ps);
mysql_select_db($name);
mysql_query("set names gb2312;");
$query="select h.hid,h.name,h.city,h.info,r.type,r.price from hotel h,room r where h.rid=r.rid;";
$result=mysql_query($query,$conn);
echo "<table border='1'>";
echo "<tr>";
echo "<td>ID</td>";
echo "<td>NAME</td> ";
echo "<td>CITY</td>";
echo "<td>PRICE</td>";
echo "</tr>";
while ($row=mysql_fetch_array($result))
{
echo "<td>".$row['hid']."</td>"."<td>".$row['name']."</td>"."<td>".$row['city']."</td>"."<td>".$row['price']."</td></tr>";
}
echo "</table>";
?>