Home  >  Article  >  php教程  >  php+ajax制作无刷新留言板,phpajax刷新留言板

php+ajax制作无刷新留言板,phpajax刷新留言板

WBOY
WBOYOriginal
2016-06-13 08:52:261058browse

php+ajax制作无刷新留言板,phpajax刷新留言板

本文就是和大家分享一款由php结合ajax实现的无刷新留言板,先给大家看一下最后的效果图:

数据库连接代码如下:

<&#63;php
$conn = @mysql_connect("localhost","root","root") or die ("MySql连接错误");
mysql_select_db("demo",$conn);
mysql_query("set names 'utf8'");
&#63;>

index.php文件代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="bbs.css" type="text/css" rel="stylesheet">
<title>无刷新显示回帖</title>
<script src="bbs.js" type="text/javascript"></script>
</head>

<body>
<h1>无刷新显示回帖</h1>
<div id="thread">
<&#63;php
include("conn.php");
$sql = "select * from `bbs_post` where `threadid` ='1' order by id asc";
$query =mysql_query($sql);
while($row = mysql_fetch_array($query)){ 
&#63;>
  <div class="post" id="post<&#63;php echo $row['id'];&#63;>">
        <div class="post_title"><&#63;php echo $row['title'];&#63;> [<&#63;php echo $row['username'];&#63;>]</div>
        <div class="post_content"><pre class="brush:php;toolbar:false"><&#63;php echo $row['content'];&#63;>
回帖
姓名:
标题:
内容:
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn