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

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft