无JS,完全php面向过程数据分页实现代码
复制代码 代码如下:
//登陆页面设置的session,当session中存在name时
//session_start();
//$name = $_SESSION['name'];
//if (empty($name)){
// header("Location: error.php");
// exit();
//}
//面向过程, 数据分页显示
if(false!=($mysql = mysql_connect('本地mysql', 'mysql用户名', 'mysql密码'))){
mysql_query('set names utf8',$mysql); //设置数据库中的编码
mysql_select_db("数据库database",$mysql);
}else{
die("连接失败");
}
$pageSize = 10; //页面显示条数
$rowCount = 0; //数据总条数,从数据库获得
$sqlCount = 'select count(id) from employee';
$res1 = mysql_query($sqlCount,$mysql);
//取出数据条数
if(false!=($row=mysql_fetch_row($res1))){
$rowCount = $row[0];
}
//总页数,通过计算得到
$pageCount = 0;
$pageCount = ceil($rowCount/$pageSize);
//获取当前页
if(!isset($_GET['pageNow'])){ // 当 get/post都为空的时候赋默认值1
$pageNow = 1; //当前页数
}elseif(false!=is_numeric($_GET['pageNow']) && $_GET['pageNow']$pageNow = $_GET['pageNow'];
}else{
header("Location: ../Error/error.php");
exit();
}
//打印分页数据
echo "
echo "
id | name | age | sex | birthday | 编辑雇员 | 删除雇员 |
---|---|---|---|---|---|---|
{$row['id']} | {$row['name']} | {$row['age']} | {$row['sex']} | {$row['birthday']} | 编辑 | 删除 |
//表单控制显示页数
echo "";
echo "
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Linux new version
SublimeText3 Linux latest version

WebStorm Mac version
Useful JavaScript development tools

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),