Returning x results per page [MySQL & php]
Posted: Sat Nov 23, 2002 11:23 am
I have a script that returns all the results of a search to a page but would rather return 5 results to a page and then have a "Previous" and "Next" links or even better "[1] [2] [3] [4] NEXT" type links on the page but after finding a couple of samples of how to do this I find I am even more confused (one example was fairly complicated and the other was partly in another language and seemed to be missing the bits where they get the results out of the query and into the link)
Does anyone know where there are any examples or tutorials on creating these types of links? "I found a couple after seaching way back on the pages here but the web sites they point to don't appear to have these any more" I can get all the results for the search as shown below the problem I have is making the connection between the results and linking that to pages that return them five at a time.
Does anyone know where there are any examples or tutorials on creating these types of links? "I found a couple after seaching way back on the pages here but the web sites they point to don't appear to have these any more" I can get all the results for the search as shown below the problem I have is making the connection between the results and linking that to pages that return them five at a time.
Code: Select all
<?php
$sql=$query; // 2 TABLE JOIN QUERY
$mysql_rental_result=mysql_query($sql,$connection);
$rent_num_rows=@mysql_num_rows($mysql_rental_result);
if ( $rent_num_rows == 0 ) { // ----------------------------- // open 11
echo "<ALIGN=CENTER><B><FONT FACE="Verdana,Arial"><SPAN CLASS="style30">There are no results for your search.</SPAN></FONT></B>";
} else { // ----------------------------------------------------- // else 11
echo "<ALIGN=CENTER><B><FONT FACE="Verdana,Arial"><SPAN CLASS="style30">Your search has returned ї $rent_num_rows ] $result_text.</B>$order_str</SPAN></FONT>";
$num = 0;
# - LOOP THE RESULTS
while ($row = mysql_fetch_array($mysql_rental_result)) {
$num == $num++;
# - GET THE USER INFORMATION FROM THE PROPERTY TABLE
$sr_ID = $rowї"ID"];
// - LOAD THE REST OF THE PROPERTY VERIABLES
# - GET THE USER INFORMATION FROM THE USER TABLE
$sc_phone = $rowї"phone"];
// - LOAD THE REST OF THE USER VARIABLES
include "search_rental_table.php"; // LOAD THE TABLE
}
} // ----------------------------------------------- // close 11
?>