不多說,直接上代碼
復制代碼 代碼如下:
//鏈接數據庫'查詢
mysql_connect('localhost','username','userpwd')or die("數據庫鏈接失敗".mysql_error());
mysql_select_db('庫名');
mysql_query('set names utf8');
$sql1="select * from user ";
$query1=mysql_query($sql1);
$count=array();
while($row=mysql_fetch_assoc($query1)){
$count[]=$row;
}
$totalnews=count($count);
//判斷page
if($_GET['page']){
$page=$_GET['page'];
}else{
$page=1;
}
$start=($page-1)*$newnum;
$sql="select * from user limit $start,$newnum";
$query=mysql_query($sql);
$ret=array();
while($row=mysql_fetch_assoc($query)){
$ret[]=$row;
}
?>
//表格樣式
<div id="wrap" >
<table border="1px"; >
<?php foreach ($ret as $key=>$value){ ?>
<tr>
<td><?php echo $value['id'] ?></td>
<td><?php echo $value['username'] ?></td>
<td><?php echo $value['pwd'] ?></td>
<td>刪除|修改</td>
</tr>
<?php } ?>
<tr >
//頁面跳轉
<td colspan="4" align="center"><a href="upload.php?page=1">首頁</a> <a href="upload.php?page=<?php echo $lastpage ?>">上一頁</a> <?php echo $page; ?>/<?php echo $pagenum; ?> <a href="upload.php?page=<?php echo $nextpage; ?>">下一頁</a> <a href="upload.php?page=<?php echo $pagenum ?>">尾頁</a><input type="text" name="text" /><input type="button" value="跳轉" onclick="check(this)"/>
</td>
</tr>
</table>
</div>