澳门新葡萄京官网首页无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’,$mysqlState of Qatar; //设置数据库中的编码
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’]State of QatarState of Qatar{ // 当 get/post都为空的时候赋暗中同意值1
$pageNow = 1; //当前页数
}elseif(false!=is_numeric($_GET[‘pageNow’]) &&
$_GET[‘pageNow’]<=$pageCount){
$pageNow = $_GET[‘pageNow’];
}else{
header(“Location: ../Error/error.php”);
exit();
}
//打字与印刷分页数据
echo “”;
echo “

“;
echo “

id

 

name

 

age

 

sex

 

birthday

 

编辑雇员

 

去除雇员

 

“;
$sqList = “select id,name,age,sex,birthday from employee limit
“.($pageNow-1)*$pageSize.”,”.$pageSize;
$res2 = mysql_query($sqList,$mysql);
while (false!=($row=mysql_fetch_assoc($res2))){
echo “

{$row[‘id’]}

 

{$row[‘name’]}

 

{$row[‘age’]}

 

{$row[‘sex’]}

 

{$row[‘birthday’]}

 

编辑

 

删除

“;
}
echo “

“;
//表单调控突显页数
echo “

“;
//上意气风发页按键
if($pageNow>1){
$pageUp = $pageNow-1;
echo
“上一页 “;
}

//下豆蔻梢头页开关
if($pageNow$pageDown = $pageNow+1;
echo
“下一页 
“;
}

//后退十页按键
if($pageNow-10>0){
echo
“<<<.%22) “;
}

//向本页传递当前显示的页数,并突显第几页按键
for($i=1;$i<=$pageCount;$i++){

if($i>$pageNow-2 && $iif($i!=$pageNow){
echo
“第”.$i.”页 “;
}
}
}

//前行十页
if($pageNow+10<=$pageCount){
echo
“>>>.%22) “;
}

//显示当前页与总页数
echo “
当前页”.$pageNow.”页/共”.$pageCount.”页”;

//跳转页
echo “跳转到:页”;
echo “

“;
echo “<>”;
?>

发表评论

电子邮件地址不会被公开。 必填项已用*标注