Home > Backend Development > PHP Tutorial > 分页解决方法

分页解决方法

WBOY
Release: 2016-06-13 10:46:58
Original
786 people have browsed it

分页
$con = mysql_connect("localhost","root","123456");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("qq", $con);

$result = mysql_query("SELECT * FROM abc");

echo "







";

while($row = mysql_fetch_array($result))
  {
  echo "";
  echo "";
  echo "";
  echo "";
  echo "";
  echo "";
  }
echo "
qq jiage lirun shijian
" . $row['qq'] . "" . $row['jiage'] . "" . $row['lirun'] . "" . $row['shijian'] . "
";

mysql_close($con);
?>
这是我的代码
可是如果太多信息要拖拽很麻烦,想弄个分页,每个页面显示5条信息

但分页功能不会
谁帮我简单弄下


------解决方案--------------------
header("content-type:text/html;charset=utf-8") ;
 mysql_connect("127.0.0.1","root","") or die("连接失败");
 mysql_select_db("test");
mysql_query("set names utf8");
if(isset($_GET["pageid"]))
{
$absoultpage=$_GET["pageid"];
}
else
{
$absoultpage=1;
}
$pagesize=2;
 $r1=mysql_query("select * from product");
 $totalnum=mysql_num_rows($r1);//总的有多少条数据
 $totalpage=ceil($totalnum/$pagesize);//总的页数
 

 $sql="SELECT * FROM product limit ".($absoultpage-1) * $pagesize.",$pagesize";
 $rs=mysql_query($sql);

 echo "";
while($row = mysql_fetch_row($rs))
{
echo "";
 echo "";
 echo "";
 echo "";
 echo "";
 echo "";
echo "";
}
echo "
".$row['id']."".$row['name']."".$row['price']."".$row['num']."".$row['des']."
";
 echo "首页";
$PageUp=$absoultpage-1;
if($PageUp {

echo "上一页";
}else
{
echo "上一页";
}

 $Nextpage=$absoultpage+1;
 if($Nextpage > $totalpage)
{

echo "下一页";
}else
{
 echo "下一页";
}

echo "尾页";
?>


这个是简单的分页 自己在改改就好了
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template