A PHP paging program, error, How to solve

Source: Internet
Author: User
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. = " 
     "; $echopage. = " 
     ";//Error: notice:undefined index:hp_self in D:\setup\xampp\htdocs\products\showclass.php on line $echopage. =" 
     ";//Error: notice:undefined index:hp_self in D:\setup\xampp\htdocs\products\showclass.php on line $echopage. =" 
     "; $echopage. = " 
    
". $pages." PageFirst page Last pagePrevious page Next pageto the first\ n "; for ($i =1; $i <= $pages; $i + +) {if ($i = = $current) $echopage. = "$i \ n "; else $echopage. = "$i \ n "; } $echopage. = "Page
";


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
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.