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
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download

Atom editor mac version download

The most popular open source editor