search
Homephp教程php手册一款经典php mysql分页程序

一款经典php mysql分页程序

Jun 13, 2016 am 10:08 AM
mysqlphpcodePaginationsupplyarticleprogramclassic

一款经典php mysql分页程序 本文章提供一款php分页代码,这是一款比较简单也常的limit进来分页了,同时他还带有条件查询分页功能。

一款经典php教程 mysql教程分页程序
本文章提供一款php分页代码,这是一款比较简单也常的limit进来分页了,同时他还带有条件查询分页功能。
*/

$conn=mysql_connect($mysql_host,$mysql_user,$mysql_password) or die('连接服务器出错');
mysql_select_db($mysql_db) or die("选择数据库教程出错");
mysql_query("set names 'gbk'");
function table($t)
{
 global $mysql_table_prefix;
 return $mysql_table_prefix.$t;
}


$sql="select * from ".table('keywords')."  where 1=1 ";
$sql2="select count(*) from ".table('keywords')."  where 1=1 ";
$py=trim($_request['py']);
if($act=="search" and !empty($_post['s1']))
{
 $s1=trim($_post['s1']);//获取搜索字
 $sql .=" and (k1='$s1' or k2='$s1') ";
 $sql2 .=" and (k1='$s1' or k2='$s1') ";
}
elseif(!empty($py))
{
 $sql .=" and pinyin='$py' ";
 $sql2.=" and pinyin='$py' ";
}


$sql .=" order by pinyin ";
$rscount=mysql_query($sql2);
$rscount=@mysql_fetch_array($rscount);
$rscount=$rscount[0];//获取总记录数

$page=trim($_get['page']);//当前页数
$pagesize=30;//每页记录数
$pagecount=ceil($rscount/$pagesize);//获取总页数
$pageurl="";
if($page {
 $page=1;
 $pageurl.=" 首页 上一页";
}else
{
 $pageurl .=" 首页  上一页";
}
if($page>=$pagecount)
{
 $page=$pagecount;
 $pageurl .=" 下一页  尾页";
}else
{
 $pageurl .=" 下一页  尾页";
}

$start_rs=($page-1)*$pagesize;//开始
$end_rs=$page*$pagesize;//结束
$sql .=" limit {$start_rs},{$end_rs} ";
$res=mysql_query($sql);

?>

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use