0 Replies Latest reply on Feb 14, 2012 10:19 AM by megaman_thesecond

    multiple pages for a search result in PHP

    megaman_thesecond

      I need to create a mysql driven page which only displays a set number of the total number of results and has a row of numbers which allow the viewer to jump to a different part of the results set

      This is commonly see on forums where you get go to page 1 2 3 4 ect at the bottom

      I would want clicking on the numbers to reload the page with different listings from the database displayed,
      I MUST NOT HAVE ANY SOLUTION WHICH LOADS ALL THE LISTINGS THE FIRST TIME THE VISITOR CLICKS ON THE PAGE

       

      I can already build mysql driven pages using code similar to this

       

      $result = mysql_query(SELECT * FROM 'relevant table');

       

      $I = 0

      $P = mysql_numrows($result);

       

      while ($I =< $P){

      $price = mysql_result($result,$I,"first relevant column name");

      $name = mysql_result($result,$I,"second relevant column name");

       

      $I = $I+1;

       

      print("some relevant HTML with $price included");

      print("some relevant HTML with $name included");

      }

       

      I know that you can put limits on the mysql_query such as WHERE and LIMIT

      and I have used this sort of code to cross referance with other tables to make more complex selections.

       

      but i cant figure out how I would go about doing this

       

      Im thinking that I could use mysql_numrows() to determine the number of entries and then divide this by 10 (or however many results i want printed per page) to generate the right lengh of numbers across the bottom of the page, and print into the link for each number a GET value which is printed into the page when it loads and used to set the LIMIT search selector when mysql_query() runs.

       

      Am i thinking allong the right lines
      or should i be looking at an entirely different PHP function?