php分页
sql语句 select * from test limit ($page-1)*page,$pagesize
php函数
mysql_connect("hostname","root","password")连接数据库
mysql_select_db("sql_name“,"连接标示符")选择数据库
mysql_query("")执行数据库语句
mysql_num_rows 数据库中有多少记录
$_SERVER["REQUEST_URL"];获取当前页的url
parse_url解析url函数
$url=parse_url("http://www.fenyen.com/path?arg=adad")
他是一个把url变为数组的函数
array{
[scheme]=http
[host]=hostname
[user]=username
[pass]=password
[path]=/path
[fragment]=anchor
}
代码
$connect_test=mysql_connect("localhost","root","");
mysql_select_db("test",$connect_test);
//echo "连接成功";
mysql_query("set names utf8");
$local_url=$_SERVER['REQUEST_URI'];
$local_url=parse_url($local_url);
$local_url=$local_url[path];
//echo $local_url;
$pagesize=5;
$page=0;
$select1="select * from people";
$query_num=mysql_query($select1);
$num=mysql_num_rows($query_num);
if($pagesize
if($pageval<=0) $pageval=1;
}
if($_GET[page])
{
$pageval=$_GET[page];
$page=($pageval-1)*$pagesize;
}
$select="select * from `people`limit $page,$pagesize ";
$query=mysql_query($select);
while($row=mysql_fetch_array($query))
{
echo $row[name]."
";
}
?>