Created
December 12, 2011 07:39
-
-
Save carry/1465702 to your computer and use it in GitHub Desktop.
xiang xue xue php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text ml; charset=gb2312"> | |
<title>http://www.wzdm.net</title> | |
</head> | |
<body> | |
<?php | |
require_once("db_conn.php");//预加载db_conn.php 看是预加载不是include包含额 页面打开就加载的而且是只加载一次,db_conn.php是连接数据库用的 | |
$sql="select * from message";//列出message表所有字段记录集 | |
$rs=mysql_query($sql);//执行sql得到记录集$rs | |
$total=mysql_num_rows($rs);//得到记录集总数$total 都是固定套路了 | |
$pagesize=6;//单页记录数赋值为6 | |
$totalpage=ceil($total/$pagesize);//总页数为记录总数除以单页记录数并取整 | |
if(isset($_GET["page"])){ | |
$page=$_GET["page"]; | |
}else{ | |
$page=2; | |
}//这个if判断就是当前接收页page排错 page为空就为2 | |
$i=$pagesize*($page-1); | |
$sql.=" limit "."$i ".','." $pagesize";//查询字符串赋值填上限制条件看好是.=而不是=额前面$sql已经赋值成"select * from message"这样就得出了当前页需要查询字符串 要是再不明白看看手册吧 我没能力了 | |
$rr=mysql_query($sql);//老套路执行查询字符串得到记录集 | |
?> | |
<CENTER><table width="100%" border="1" cellspacing="1" cellpadding="3"></CENTER> | |
<tr> | |
<th colspan="7"><CENTER>留言信息浏览</CENTER></th> | |
</tr> | |
<CENTER><tr> | |
<th width="12%" >主题</th> | |
<th width="30%">留言内容</th> | |
<th width="18%">留言时间</th> | |
<th width="10%">留言者</th> | |
<th width="10%">电子邮箱</th> | |
<th width="10%">IP地址</th> | |
<th width="10%">是否删除</th> | |
</tr></CENTER> | |
<?php | |
while ($jg=mysql_fetch_array($rr)) { | |
?> | |
<tr> | |
<td bgcolor="#FFFFFF"><?php echo $jg["m_title"]?></td><!--这些都属输出数组$jg里面的东西----> | |
<td bgcolor="#FFFFFF"><?php echo $jg["m_content"]?></td> | |
<td bgcolor="#FFFFFF"><?php echo $jg["m_time"]?></td> | |
<td bgcolor="#FFFFFF"><?php echo $jg["m_user"]?></td> | |
<td bgcolor="#FFFFFF"><?php echo $jg["m_mail"]?></td> | |
<td bgcolor="#FFFFFF"><?php echo $jg["m_ip"]?></td> | |
<td><center> | |
<A HREF="contact_delete.php?m_id=<?= $jg["m_id"]?>">删除</A><BR> <!-- 用来向所连接到的地址传递参数 --> | |
</tr> | |
<?php | |
} | |
?> | |
<tr> | |
<!-- <td colspan="2" bgcolor="#FFFFFF"> --> | |
<?php | |
$first=1;//首页初始化赋值为1 | |
$pre=$page-1;//得到前页 | |
$next=$page+1;//得到下页 | |
$last=$pagesize;//得到末页 | |
if($page>1){ | |
echo "<a href =".$_SERVER['PHP_SELF']."?page=".$first.">首页</a>"; | |
echo "<a href =".$_SERVER['PHP_SELF']."?page=".$pre.">上页</a>"; | |
} | |
if($page<$totalpage){ | |
echo "<a href =".$_SERVER['PHP_SELF']."?page=".$next.">下页</a>"; | |
echo "<a href =".$_SERVER['PHP_SELF']."?page=".$last.">末页</a>"; | |
}//这个if判断就是防止page超出报错的 这你要是再看明白还是那句老话 看看手册吧... | |
//5分少了点 打字辛苦^-^ | |
?> | |
</td> | |
</tr> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment