自己总结了些屁经验 1.用ajaxpost数据到后台页面后,接着要重新连接数据库,别以为用之前的session连接过就可以了 2.为了处理返回乱码的问题,我添加了header("Content-Type:text/html;charset=GB2312");就可以正常显示了,后来在firefox下检验,却提示我下载这个网页,上网搜了不少资料,得到一个模糊的认识就是网页代码有语法错误,firefox为了安全起见不会直接显示而是提示下载,我重新检查了刚才那条语句,发现自己多写了个“”,把它去掉后问题就解决了,哈哈,所以遇到这样的问题,好好检查一下htmltag吧,毕竟firefox可不像ie那样smart 3.最后说一句,做website的开发者,要负责任,别以为在ie下测试通过就万事大吉,毕竟不是所有人都用ie,还得要在别的浏览器下多做测试,这样才显示出你的专业水准 ajax脚本: <div class="codetitle"><a style="CURSOR: pointer" data="56979" class="copybut" id="copybut56979" onclick="doCopy('code56979')"> 代码如下:<div class="codebody" id="code56979">
调用: <div class="codetitle"><a style="CURSOR: pointer" data="48693" class="copybut" id="copybut48693" onclick="doCopy('code48693')"> 代码如下:<div class="codebody" id="code48693">header("Content-Type:text/html;charset=GB2312"); $pagesize=10; //echo$_POST['page']; $result=mysql_query("Selectcount(DISTINCThotelname)FROM".TBL_HOTELS); $myrow=mysql_fetch_array($result); $numrows=$myrow[0]; $pages=intval($numrows/$pagesize); if($numrows%$pagesize) $pages++; if(isset($_POST['page'])){ $page=intval($_POST['page']); } else{ //设置为第一页 $page=1; } $first=1; $prev=$page-1; $next=$page+1; $last=$pages; //计算记录偏移量 $offset=$pagesize($page-1); //读取指定记录数 $result=mysql_query("selecthotelname ,count()from".TBL_HOTELS."GROUPBYhotelname orderbyiddesclimit$offset,$pagesize"); $num=mysql_num_rows($result); while($row=mysql_fetch_array($result,MYSQL_NUM)){ $hotelname[]=$row[0]; $countpeople[]=$row[1]; } for($a=0;$a<$num;$a++) { //$result=mysql_query("selectcount(title)from".TBL_Comments."wheretitle ="".$title[$a]."""); //$row=mysql_fetch_row($result); echo"<TABLEstyle="MARGIN-BOTTOM:20px"cellSpacing=0cellPadding=0width=100%border=0>n"; echo"n"; echo"n"; echo"<TDstyle="PADDING-TOP:5px"vAlign=topalign=leftwidth=80>n"; //rating_bar($title[$a],5); echo"n"; echo"<TDstyle="PADDING-TOP:5px"align=leftwidth=100%><Atitle=$hotelname[$a]style="FONT-SIZE:14px"href=#>$hotelname[$a]n"; echo" n"; echo"n"; echo" | n"; echo"<TDstyle="PADDING-LEFT:0px">n"; echo"<IMGsrc="images/comment.gif"border=0>推荐人数:($countpeople[$a])|n"; echo"平均分:(".$count."票)|评论数:()n"; echo" |