各位请进: 菜鸟有小问题.
源码:
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<?php
$table='test_1';
$db=mysql_connect("localhost","root","1980119");
mysql_select_db("qzy",$db);
$query = "SELECT * FROM $table";
$result = mysql_query($query);
$num = mysql_num_rows($result); // 总的记录数
$numbers = ceil($num/10); //总的页数
$page=$_GET['page'];
if(!$page){ //$page是传的页数参数,如果是该参数还没有被传,就设成是1,就是当前页
$page=1;
}else{
if($page<1) $page=1;
}
if($page>=$numbers)
{
$page=$numbers;
}
echo("this is test:".$page);
$temp = ($page-1)*10; // $temp 显示每页的起点(数据库里面的记录起点,比方说从第11条显示)
$str = "select * FROM $table order by id DESC limit $temp,10"; //从上面的起点开始查询出20条数据
$query = mysql_query($str);
while($row=mysql_fetch_row( $query))
{
echo "<p>$row[0]</p>" ;
}
?>
<body><a href=ok_1.php?page=1>首页</a>
<a href=ok_1.php?page=<?php echo $page-1;?>> pre</a>
<a href=ok_1.php?page=<?php echo $page+1;?>>下页</a>
<a href=ok_1.php?page=<?php echo $numbers;?>>尾页</a>
</body>
</html>
错误提示:
Notice: Undefined index: page in D:\test1\ok_1.php on line 14
谢谢各位指教: