conn.php
<?php
/*
* Created on 2010-1-6
* Author:CHAUVET
* Function:连接字符串
*/
$conn=@mysql_connect("localhost","root","")or die("连接数据库出错!");
mysql_select_db("newdb",$conn);
mysql_query("set names 'gb2312'");
function ReplaceSomeWords($words){
$words=str_replace("/n","<br/>",str_replace(" "," ",$words));
return $words;
}
?>
list.php
<?php
/*
* Created on 2010-1-7
* Author: CHAUVET
* Function:
*/
include("conn.php");
$pageSize=5;
$url=$_SERVER["REQUEST_URI"];
$url=parse_url($url);
$url=$url[path];
$numq=mysql_query("select * from `splitpage`");
$num=mysql_num_rows($numq);
if($_GET[page]){
$pageval=$_GET[page];
$page=($pageval-1)*$pageSize;
$page.=',';
}
if($num>$pagesize){
if($pageval<=1){
$pageval=1;
}
echo "共 $num 条 "."<a href=$url?page=".($pageval-1).
">上一页</a> <a href=$url?page=".($pageval+1).">下一页</a>";
}
$sql="select * from `splitpage` limit $page $pageSize";
$query=mysql_query($sql,$conn);
while($row=mysql_fetch_array($query)){
echo("<hr/>".$row['id']." | ".$row["name"]." | ".$row[sex]);
}
?>