A php paging program reports an error. how can this problem be solved?-php Tutorial

Source: Internet
Author: User
For a PHP paging program, the following error occurs: phpcode=de_once (conn. php); if (isset ($ _ GET [pclass]) {$ p_pclass];} else {$ p _ ;}$ respagemysql_query (& quot; SELECTCOUNT (*) a php paging program reports an error
This is a 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 qualified records in the data table while ($ row = mysql_fetch_assoc ($ respage) {$ num = $ row [0]; // This row reports an error: notice: Undefined offset: 0 in D: \ setup \ xampp \ htdocs \ products \ showclass. php on line 88} $ recordnum = 40; // how many records are displayed on each page, $ pages = ceil ($ num/$ recordnum ); // total number of pages if (@ $ _ GET ["page"]) // Obtain the parameter page in the url {// $ pre and $ next are the values of the connection parameter page in the previous and next pages. // if the parameter in the url is 1, set the current page to the previous one, $ pre as one, and $ next as 2 if ($ _ GET ["page"] = 1) {$ current = 1; // the current page $ pre = 1; // $ pre is the previous page $ next = 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), set the value of the current page to the parameter obtained in the url, $ pre is the current page minus 1, $ next is added with 1} else {$ current = 1; $ pre = '1'; $ next = 2;} // if there is no parameter page in the url, set the current page to 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 120 $ echopage. =" 
     "; // Error: Notice: Undefined index: HP_SELF in D :\setup \ xampp \ htdocs \ products \ showclass. php on line 120 $ echopage. =" 
     "; $ Echopage. =" 
    
". $ Pages." pagePage 1 Last pagePrevious Page and Next pageTo\ N "; for ($ I = 1; $ I <= $ pages; $ I ++) {if ($ I = $ current) $ echopage. ="$ I\ N "; else $ echopage. ="$ I\ N ";}$ echopage. ="Page
";


The following is the code for paging:

PHP code
  



===== Error reported on the WEB:

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 row returns an error
Because mysql_fetch_assoc returns an associated array with no subscript
Change to mysql_fetch_array.

HP_SELF should be PHP_SELF

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.