日期:2014-05-16 浏览次数:20734 次
<script type="text/javascript">
function require(str)
{
var xmlHttp;
xmlHttp=null;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
var url="read.php";
xmlHttp.onreadystatechange=function()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
// document.getElementById("liebiao").innerHTML=xmlHttp.responseText;
var response;
response = xmlHttp.responseText;
alert(response);
document.getElementById("liebiao").innerHTML=response;
// alert(response);//这就是我用来定住页面的alert。。
return
}
}
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded;charset=utf-8");
xmlHttp.setRequestHeader("If-Modified-Since","0");
xmlHttp.send("&require=" + str);
alert("正在加载,请稍候");//这一句似乎能用来占位,注释掉以后,程序像是跑飞了。。
}
</script>
<form>
<input id="all" name="all" type="submit" value="全部留言" onclick="require(this.value)"/>
<input id="have" name="have" type="submit" value="已处理" onclick="require(this.value)"/>
<input id="havent" name="havent" type="submit" value="未处理" onclick="require(this.value)"/>
</form>
<?php
$con = mysql_connect("localhost","root","cyx1991430");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
if($_POST["require"]=="全部留言")
{
$result = mysql_query("SELECT * FROM liuyan");
echo "<table style='width:400px' border='1'>
<tr>
<th>留言者</th>
<th>留言时间</th>
<th>联系邮箱</th>
<th>留言状态</th>
<th>查看详情</th>
</tr>";
while($row = mysql_fetch_array($result))