- 论坛徽章:
- 0
|
想试着通过乔楚大哥的xajax例子把自己的网站改变成无缝连接的感觉……但是现在有个问题,向各位请教。
- function displayChat()
- {
- $fp=fopen("chat.inc.php","r");
- $file=file_get_contents("chat.inc.php");
- $objResponse = new xajaxResponse();
- $objResponse->setCharEncoding("gb2312");
- $objResponse->addAssign("submain","innerHTML",$file);
- return $objResponse->getXML();
- }
复制代码
想法是让submain显示chat.inc.php中的代码,但是这样却显示不正常。显示的也不是纯php代码。
下面是chat.inc.php的代码:
- <?
- @ $db=mysql_pconnect("localhost","test","test");
- if(!$db)
- {
- echo "数据库异常,请联系管理员";
- exit;
- }
- mysql_select_db("user");
- $sql="select msg_id,msg_author,msg_content,msg_time from message where msg_top=0 order by msg_time desc";
- $result=mysql_query($sql);
- $num_result=mysql_num_rows($result);
- if($num_result>0)
- {
- for($i=$num_result;$i>0;$i--)
- {
- $row = mysql_fetch_array($result);
- echo "<div class=chattextbox>";
- echo "<div class=chatuserbox><div class=chatimagebox><img src=\"index/1.gif\"></img></div>".$row["msg_author"]." 于".$row["msg_time"]." 说:</div>";
- if($row["msg_author"]==$valid_user)
- {
- echo "<div class=chateditbox><a href=editmessage.php?id=".$row["msg_id"]."><img alt=\"编辑留言\" src=\"index/edit.gif\"></img></a> <a href=delmessage.php?id=".$row["msg_id"]."><img alt=\"删除留言\" src=\"index/delete.gif\"></img></a></div><br />";
- echo "";
- }
- else
- echo "<br />";
-
- echo "</div>";
- echo "<div class=chatcontentbox>".nl2br(stripslashes($row["msg_content"]))."<br /></div>";
- }
- }
- if(session_is_registered("admin_user"))
- echo "<div id=\"chatadminbox\"><a href=\"adminmessage.php\">您是管理员,进入消息管理页面</a></div><br />";
-
- include("chat.inc");
- unset($message);
- ?>
复制代码
[ 本帖最后由 HonestQiao 于 2005-12-28 09:04 编辑 ] |
|