I found a tutorial according pagination. http://papermashup.com/easy-php-pagination/
I tried the code and it work. but every time the first index is reload(first result in pagination).
I got this message.
Notice: Undefined index: page in C:\\xampp\\htdocs\\sim\\registrar\\index.php on line 207
how can I remove this message?
here's the code..
$targetpage = "index.php";
$limit = 3;
$query = "SELECT COUNT(*) as num FROM advisoryclass";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages['num'];
$stages = 3;
$page = mysql_escape_string($_GET['page']);//this part
if($page){
$start = ($page - 1) * $limit;
}else{
$start = 0;
}
thanks
You're assuming page
is set when that's not always going to be the case; hence the error.
Change this:
$page = mysql_escape_string($_GET['page']);//this part
To:
$page = ( isset( $_GET['page'] ) ) ? mysql_escape_string( $_GET['page'] ) : 1;
In the code above we're checking the page $_GET
variable has been set and using 1 as a fallback.
You may want to look at the functions you're using with the database too.
add a check in order to see if the parameter is in the get array:
$page = mysql_escape_string(isset($_GET['page']) ? $_GET['page'] : 0);
this is a ternary comparison in order to make it shorter than an if statement.
如果$ page不存在,则需要处理。
$page = mysql_escape_string(isset($_GET['page']) ? $_GET['page'] : 0);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.