Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to do next and previous thing and thread per page

Status
Not open for further replies.

Phutie

Programmer
Jul 31, 2000
29
PH
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 &quot;Prev&quot; and &quot;Next&quot; 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, &quot;SELECT * FROM mytable&quot;);<br>$count = pg_NumRows($result);<br><br>.<br>.<br>.<br><br><br>//<br>// Output &quot;Prev&quot; and &quot;Next&quot; links at top of page<br>//<br>if($base &gt; 0) {<br>&nbsp;&nbsp;&nbsp;&nbsp;$tmp = $base - $pagesize;<br>&nbsp;&nbsp;&nbsp;&nbsp;if($tmp &lt; 0) { $tmp = 0; }<br>&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;A HREF=\&quot;showlist.php?query=$query&base=$tmp\&quot;&gt;&lt;B&gt;Prev&lt;/B&gt;&lt;/A&gt;\n&quot;;<br>}<br>else {<br>&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Prev&quot;;<br>}<br><br>if($base + $pagesize &lt; $count) {<br>&nbsp;&nbsp;&nbsp;&nbsp;$max = $base + $pagesize;<br>&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;A HREF=\&quot;showlist.php?query=$query&base=$max\&quot;&gt;&lt;B&gt;Next&lt;/B&gt;&lt;/A&gt;\n&quot;;<br>}<br>else {<br>&nbsp;&nbsp;&nbsp;&nbsp;$max = $count;<br>&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Next&quot;;<br>}<br><br>.<br>.<br>.<br><br>//<br>// Output current part of the table<br>//<br>echo &quot;&lt;hr&gt; &lt;br&gt;&quot;; # start a new line after a horizontal rule to look nice<br><br>for(; $base &lt; $max; $base++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;$row = pg_fetch_array ($result, $base);<br>&nbsp;&nbsp;&nbsp;&nbsp;echo $row[myfield] . &quot;&lt;BR&gt;&quot;;<br>}<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top