87,992
社区成员
发帖
与我相关
我的任务
分享
<!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" />
<title>无标题文档</title>
<style>
#searchResult{width:920px;height:400px; OVERFLOW: scroll; OVERFLOW-X: hidden; border:1px dotted black; margin-top:1px;background-color:#00f600; }
</style>
<script>
var cur_id_no;
var xmlhttp;
var baseURl="show.php";
function $(str){return (document.getElementById(str));}
function getXMLRequester(){
var xmlhttp_request=false;
try{
if(window.ActiveXObject) {
for (var i=5;i>-1;i--){
try{
if (i==2){
xmlhttp_request=new ActiveXObject("Microsoft.XMLHTTP");
}else{
xmlhttp_request=new ActiveXObject("Msxml2.XMLHTTP."+i+".0");
}
break;
}catch(e){
xmlhttp_reques=false;
}
}
}else if (window.XMLHttpRequest) {
xmlhttp_request=new XMLHttpRequest();
}
}catch(e){
xmlhttp_request=false;
}
return xmlhttp_request;
}
function start_search(){
xmlhttp=getXMLRequester();
xmlhttp.onreadystatechange=xmlhttp_onreadystatechange;
xmlhttp.open("GET",baseURl,true);
xmlhttp.send(" ");
}
function xmlhttp_onreadystatechange(){
if(xmlhttp.readyState==4){
if(xmlhttp.status==200){
$("searchResult").innerHTML=xmlhttp.responseText;
}else{
$("searchResult").innerHTML="载入失败,返回码:"+xmlhttp.status;
}
}else{
$("searchResult").innerHTML="载入中,当前状态:"+xmlhttp.readyState;
}
}
function start_edit(){
alert ($("on_sele_radio").value);
}
window.onload= function(){
$("cmd_search").onclick=start_search;
start_search();
}
</script>
</head>
<body>
<DIV id="searchBar">
<input id="cmd_search" type="button" onclick= "start_search()" value="刷新"/>
<input id="cmd_edit" type="button" onclick= "start_edit()" value="修改"/>
</DIV>
<div id="searchResult"></div>
</body>
</html>
<?
$mysql_server_name = "localhost";
$mysql_username = "root";
$mysql_password = "123456";
$mysql_database = "gbook";
$sql = "SELECT * FROM gbook ORDER BY 'id' DESC"; //排序 后留言的在前面显示
$conn = mysql_connect($mysql_server_name,$mysql_username,$mysql_password);
mysql_query("set names utf8;");
mysql_select_db($mysql_database,$conn);
$result = mysql_query($sql);
?>
<table width="800" border="1">
<th width="170">日期时间</th>
<th width="80">IP</th>
<th width="80">姓名</th>
<th>性别</th>
<th width="100" >Email地址</th>
<th width="180">留言内容</th>
<th>选择</th>
<?
while($row = mysql_fetch_row($result))
{ // ----if语句判断男女------
if($row[2]==1)
{ $gender = '男';}
else
{ $gender = '女'; }
?>
<tr>
<td> <p><?=$row[6]?> <p></td>
<td> <p> <?=$row[5]?> </p> </td>
<td> <p><?=$row[1]?><p> </td>
<td> <p><?=$gender?> <p></td>
<td> <p> <?=$row[3]?></p></td>
<td> <p><?=nl2br($row[4])?><p></td>
<td> <p><input id="on_sele_radio" type="Radio" value=<?$row[0]?> > <?=$row[0]?>
</p>
</td>
</tr>
<?
}
mysql_free_result($result);
?>
</table>