Hi, im doing a search engine made of phphoo. I want to add a next and previous link if it founds more than 10 keyword searches. Also, how do you do the thread per page thing like breaking your searches to 10, 20 or 50?<br><br>thanks<br><br>Phutie
Here is some sample code that does this, using "Prev" and "Next" links at the top of a list of data items. You set $pagesize to the size of the chunk you want to view at a time (10 in your case).<br><br>//<br>// Set pagesize, read database, determine number of records in list<br>//<br>$pagesize = 10;<br>$result = pg_Exec ($conn, "SELECT * FROM mytable"<br>$count = pg_NumRows($result);<br><br>.<br>.<br>.<br><br><br>//<br>// Output "Prev" and "Next" links at top of page<br>//<br>if($base > 0) {<br> $tmp = $base - $pagesize;<br> if($tmp < 0) { $tmp = 0; }<br> echo "<A HREF=\"showlist.php?query=$query&base=$tmp\"><B>Prev</B></A>\n";<br>}<br>else {<br> echo "Prev";<br>}<br><br>if($base + $pagesize < $count) {<br> $max = $base + $pagesize;<br> echo "<A HREF=\"showlist.php?query=$query&base=$max\"><B>Next</B></A>\n";<br>}<br>else {<br> $max = $count;<br> echo "Next";<br>}<br><br>.<br>.<br>.<br><br>//<br>// Output current part of the table<br>//<br>echo "<hr> <br>"; # start a new line after a horizontal rule to look nice<br><br>for(; $base < $max; $base++) {<br> $row = pg_fetch_array ($result, $base);<br> echo $row[myfield] . "<BR>";<br>}<br>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.