静态页面调用动态数据问题

xuhui37208 2011-07-12 11:08:10
我有一个页面是静态的 HTML 有些地方需要 掉用数据库的内容 我自己弄不好 各位大虾帮忙看下我的代码
jquery 不太会 希望有前辈能帮忙写写或者修改一下 我正好学习一下 谢谢了

html页面
<script type="text/javascript" src=" https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
<!--
var hotels_name=$('#hotels_name').val();

$.get('http://localhost/chinahotelsmap/control/a1.php?hotels_name='hotels_name'',function(data){
$('#s').after(data);
});
//-->
</script>
<body>
<table width="932" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><p class="STYLE1"><span class="STYLE4"><img src="../../pic1/chinahotelsmap.GIF" width="932" height="87" /><br />
</span><span class="text-bar">Beijing Hotel | Shanghai Hotel | Xian Hotel | Guilin Hotel | Guangzhou Hotel | Hangzhou Hotel | Kunming Hotel | Shenzhen Hotel | Sanya</span><br />
<span class="text"><img src="../../pic1/arrow_on.gif" width="5" height="9" /><img src="../../pic1/arrow_on.gif" width="5" height="9" /> <a href="#">Home</a> : <a href="#">Beijing Hotel</a> : </span><br />
<br />
<br />
<span class="text-h1" id="hotels_name" name="hotels_name">北京红房子酒店</span></p>
<p class="STYLE1"><span class="text"><img src="../../pic1/friendship-hotel-beijing-exterior-view.jpg" width="300" height="200" align="right" />Radisson SAS Hotel Beijing is located in the commercial and embassy district and adjacent to the China International Exhibition Center (CIEC). The Hotel is conveniently located only 20 minutes drive from the Beijing International Airport.</span></p>
<p class="text"><span class="text-bold">Address</span>: 6A East Beisanhuan Road, Beijing<br />
Telephone: 86-10-64663388<br />
Star rating:</p>
<p class="text"><span class="text-bold">Surrounding attractions</span>: China International Exhibition Center<br />
More pictures: room, meetingroom, chinese address</p>
<p class="text-bold"> Book This Hotel</p>
<p class="text"><span class="text-bold">Location</span><br />
18 km to Airport<br />
19 km to Railway station<br />
10 km to downtown</p>
<p class="text"><span class="text-bold">Accommodation</span><br />
Radisson SAS Hotel Beijing has 362 air-conditioned guest rooms and suites in a variety of room styles, such as Italian and Chinese. The Royal Club rooms are even more spacious and located on the top three floors, which offer additional luxuries catering to your needs including exclusive use of the Royal Club Lounge for breakfast, afternoon tea or pre dinner aperitifs.<br />
All rooms are equipped with satellite TV, direct dial telephone with voice mail, mini bar and internet access.<br />
<br />
<br />
</p>
<table width="932" border="0" cellpadding="0" cellspacing="1">
<tr id="s">
<td width="201" class="text-white"><span class="text">Room
type</span></td>
<td width="165" class="text-white"><span class="text">Rate
(per night)</span></td>
<td width="232" class="text-white"><span class="text">Reserve </span></td>
<td width="329" class="text-white"><span class="text">Validity</span></td>
</tr>



PHP页面

$hotels_name=@$_REQUEST['hotels_name'];
//echo $hotels_name;
$sql="select hotels_type_name,hotels_price from hotels join hotels_type on hotels.hotels_type_id=hotels_type.hotels_type_id where hotels_name='$hotels_name'";
$res=mysql_query($sql);
while($row=mysql_fetch_array($res,MYSQL_BOTH)){
$hotels_type_name = $row['hotels_type_name'];
$hotels_price = $row['hotels_price'];
echo('
<tr id="hotelsprice" name="hotelsprice">
<td id="hotels_type_name" name="hotels_type_name" bgcolor="#99CCFF" class="text">'.$hotels_type_name.'</td>
<td id="hotels_price" name="hotels_price" bgcolor="#99CCFF" class="text"><span class="text">'.$hotels_price.'RMB </span></td>
<td bgcolor="#99CCFF" class="text"><span class="text"><a href="../../submithotel/form.php?HotelName=***&RoomType=***&HotelTel=***"><img src="../../pic1/reserve-china-hotel.gif" alt="reserve hotel" width="70" height="18" border="0" /></a></span></td>
</tr>
');
}
...全文
251 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuhui37208 2011-07-13
  • 打赏
  • 举报
回复
还有 需要传一个字符串到PHP页面去 JS的知识 缺乏的太少了 !
xuhui37208 2011-07-13
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 ericdu 的回复:]
静态页面通过<script type="text/javascript" src="your.php"></script>这样可以直接调用php页面中输出的内容。
php页面中的输出要加上document.write,例如:
echo "document.write('<table><tr><td>".$hotels_type_name."</td></tr></table>');";
[/Quote]
这样写的话 怎么控制 那个放动态数据的容器呢
lijpwsw 2011-07-12
  • 打赏
  • 举报
回复
JQuery没有那么难,看下手册就会啦,动态的就是ajax……
xuhui37208 2011-07-12
  • 打赏
  • 举报
回复
刚接触者玩意 代码写的很不规范
床上等您 2011-07-12
  • 打赏
  • 举报
回复
先直接执行 php 看是否有输出错误。

js接收时先把接收到的串 alert 出来。

---
最好使用 firefox 的 firebug 插件,功能很强大,可能查看 ajax 的数据。
EricDu 2011-07-12
  • 打赏
  • 举报
回复
静态页面通过<script type="text/javascript" src="your.php"></script>这样可以直接调用php页面中输出的内容。
php页面中的输出要加上document.write,例如:
echo "document.write('<table><tr><td>".$hotels_type_name."</td></tr></table>');";
xuhui37208 2011-07-12
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 lijpwsw 的回复:]
JQuery没有那么难,看下手册就会啦,动态的就是ajax……
[/Quote]
就是研究看了一下 还是弄不成功 自己也找不到那里错误啊

大虾 帮帮看看呗 感谢了!

20,359

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧