A PHP paging program, error
This is the paging program:
PHP Code
Include_once (' conn.php '), if (Isset ($_get[' Pclass ')) {$p _class=$_get[' pclass '];} else {$p _class= ';} $respage = mysql_query ("Select COUNT (*) from product where p_class= ' $p _class ';"); $num is the total number of qualifying records in the datasheet while ($row = Mysql_fetch_assoc ($respage)) {$num = $row [0];//This line error: notice:undefined offset: 0 in D:\setup\xampp\htdocs\products\showclass.php on line $recordnum = 40; How many records are displayed per page, $pages = ceil ($num/$recordnum); How many pages are there if (@$_get["page"])//Gets the parameters in the URL page {//$pre and $next The value of the page for the connection parameters of the previous and subsequent pages//AS The parameter in the URL is 1, the current page is set to 1 previous page, $pre is one, $next is 2 if ($_get["page"]==1) {$current = 1;//Current page $pre = 1; $pre is the $next of the previous page = 2; $next is the next page} else {$current = $_get["page"]; $pre = $current-1; $next = $current +1; }//If the parameter in the URL is not one (not the first page), the current page is evaluated to the parameter obtained in the URL, $pre minus 1 for the current page, $next to add 1} else {$current = 1; $pre = ' 1 '; $next = 2; }//If there is no parameter page in the URL, the current page is 1, $pre =1, $next =2 $now = ($current-1) * $RECORDNUM; $echopage = "
"; $echopage. = "
". $pages." Page | "; $echopage. = "
First page |
Last page | ";//Error: notice:undefined index:hp_self in D:\setup\xampp\htdocs\products\showclass.php on line $echopage. ="
Previous page Next page | ";//Error: notice:undefined index:hp_self in D:\setup\xampp\htdocs\products\showclass.php on line $echopage. ="
to the first\ n "; for ($i =1; $i <= $pages; $i + +) {if ($i = = $current) $echopage. = "$i \ n "; else $echopage. = "$i \ n "; } $echopage. = "Page | "; $echopage. = "
";
Here's the code that needs to be paged:
PHP Code
===== on the Web side error:
notice:undefined offset:0 in D:\setup\xampp\htdocs\products\showclass.php on line 88
notice:undefined index:hp_self in D:\setup\xampp\htdocs\products\showclass.php on line 120
notice:undefined index:hp_self in D:\setup\xampp\htdocs\products\showclass.php on line 120
notice:undefined index:hp_self in D:\setup\xampp\htdocs\products\showclass.php on line 121
------Solution--------------------
$num = $row [0];//This line error
is because MYSQL_FETCH_ASSOC returns an associative array with no subscript
Change to Mysql_fetch_array
The hp_self should be php_self