PHP? ??? ?? ?? ???? ?? ??
?? ???? ????? ??? ??? ? ?? ???? ???? ?? ?? ???? HTML ??? ???????.
<!DOCTYPE html> <html> <heah> <meta charset="utf-8"> <title></title> <style type="text/css"> table{width:400px;} th{height:25px;} td{text-align:center;height:45px;} </style> </heah> <bohy> <table cellpadding="0" cellspacing="0" border="1"> <tr> <th>ID</th> <th>標題</th> <th>內(nèi)容</th> <th>時間</th> <th>操作</th> </tr> <tr> <td>1</td> <td>明天過后</td> <td>大家好</td> <td>15-6-28</td> <td> <a href="modifynew.php">修改</a> <a href="delnew.php">刪除</a> </td> </tr> <tr> <td colspan="5"> <a href="">首頁</a> <a href="">上一頁</a> <a href="">下一頁</a> <a href="">末頁</a> </td> </tr> </table> </bohy> </html>
?? ???????? ?????
header("Content-type: text/html; charset= utf-8");//??? ??
$con =@mysql_connect("localhost","root","root") ?? die("?????? ?? ??" );
mysql_select_db('news') or die(" ??? ??????? ? ? ????.");
mysql_query("set names utf8");//??????? ?? ??? ?????
?? ?? ???? ??? do paging
//??? ??
$page = isset($_GET[ 'page'])?intval($_GET['page']):1;//?? ??? ??? ????, ??? ???? ?????. 1
$num=1;//
$sql="select * from new";
$result=mysql_query($sql);
$total=mysql_num_rows($result);//? ?? ??? ?
$pagenum =ceil($total/$num);//?? ??? ?? ?????
// ??? ??? ?? ???? apge? ?? ??? ?? pagenum?? ?? ?? ???? ?????.
if($page> $pagenum || $page == 0){
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ?? ??? ? ?? ??? ? ?? ??‐ ? ? ? ? ? ? ‐ ‐ ? ? ? ? ? ? ? ? ? ? ?~? ? ? ? ? ?;history.go(-1);</script>";
??;
}
$offset=($page -1)*$num;
/* ? ?? ???? (1-1)*10=0?? ? ?? ???? (2-1)*10=10? ?? ??? ? ?? ????? ? ???? ?????. . (??? ??? ? - 1) * ? ???? ???? Limit? ? ?? ???? ?? ?????. */
$sql="select * from new order by id desclimit $offset,$num ";
$info =mysql_query ($sql); //?? ??? ??? ??? ???? ?????
if($info && mysql_num_rows($info)){
while($row=mysql_fetch_assoc($info)){
$data[ ]=$row ;
????????????????????????????????????????????????????????????????????????????????????????????????|
<table cellpadding="0" cellpacing="0" border="1">
?? ??? ?<tr>
?? ??? ??? ?<??>ID</th>
?? ??? ??? ?<??>標題</th>
????? ??? ?< th>內(nèi)容</th>
?? ??? ??? ?<th>時間</th>
?? ??? ??? ?<th>操??</th>
?? ??? ?</tr>
?? ?? ?<?php
?? ??? ??? ??? ?if(!empty($data) ){
?? ??? ??? ??? ??? ?foreach($data as $row){
?? ??? ??>
?? ??? ?<tr>
?? ??? ??? ?<td><?php echo $row['id'];></t d>
?? ??? ??? ?< ;td><?php echo $row['title'];?></td>
?? ??? ??? ?<td><?php echo $row['content'];?></td>
?? ??? ??? ?<td><?php echo date('y-m-d',$row['messtime']);?></td>
?? ??? ??? ?<td>
?? ??? ??? ??? ?<a href="modifynew.php ?id=<?php echo $row['id'];?>">修改</a>
?? ??? ??? ??? ?<a href="delnew.php?id=<?php echo $row[' id'];?>">刪除</a>
?? ??? ??? ?</td>
?? ??? ?</tr>
?? ??? ?<?php
?? ??? ??? ??? ?}
?? ???? ?}
?? ??? ??? ?$first=1;
?? ??? ??? ?$prev=$page- 1;
?? ??? ??? ?$next=$page+1;
?? ??? ??? ?$last=$pagenum;
?? ??? ??>
<tr>
????????????????????????????????????????????????????????????????????????????????????????????????????????????????< a href="newlist.php?page=<?php echo $prev ?>">?? ??? ????????????????????????????????????????????????????????????? ?>">?? ???</a>
;/td>
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????