//Session set on the login page, when name exists in the session
//session_start();
//$name = $_SESSION['name'];
//if (empty($name)){
// header("Location: error .php");
// exit();
//}
//Process-oriented, data is displayed in pages
if(false!=($mysql = mysql_connect('local mysql', 'mysql username', 'mysql password'))){
mysql_query('set names utf8',$mysql); //Set the encoding in the database
mysql_select_db("database database",$mysql);
}else{
die("Connection failed");
}
$pageSize = 10; //Number of items displayed on the page
$rowCount = 0; / /Total number of data, obtained from the database
$sqlCount = 'select count(id) from employee';
$res1 = mysql_query($sqlCount,$mysql);
/ /Get the number of data items
if(false!=($row=mysql_fetch_row($res1))){
$rowCount = $row[0];
}
//Total The number of pages is calculated by
$pageCount = 0;
$pageCount = ceil($rowCount/$pageSize);
//Get the current page
if(!isset($_GET ['pageNow'])){ // When get/post are empty, assign the default value 1
$pageNow = 1; //Current page number
}elseif(false!=is_numeric($_GET[ 'pageNow']) && $_GET['pageNow']<=$pageCount){
$pageNow = $_GET['pageNow'];
}else{
header("Location: .. /Error/error.php");
exit();
}
//Print paging data
echo "
";
echo "
";
echo "< tr>id | name | age | ;Edit employee Delete employee | ";
$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']} | < ;td>Edit Delete |
";
}
echo "
";
//Form control display page number
echo "
";
echo "
";
?>