loop control for record navigation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mrpaulfrank
Forum Commoner
Posts: 33
Joined: Sun Jun 23, 2002 3:39 am

loop control for record navigation

Post by mrpaulfrank »

this is what i have so far. its a working loop which displays each requested item's attributes in a table (within a larger table):

Code: Select all

<?php

echo "<table width="100%" border="0" cellspacing="0" cellpadding="0">\n";  // begin master table
echo "<tr>\n";  // begin master table's one and only row

while($row_Recordset1 = mysql_fetch_assoc($Recordset1)) 
	&#123; // start while loop
		$image = $row_Recordset1&#1111;'image']; // define image number for each loop	
		if($genre = "comedy")
		&#123; // start if loop
		echo "<td>\n";  // begin master table column to be repeated by loop
		echo "<table width="100%" border="0" cellspacing="0">\n"; //begin sub-table
		echo "<tr>\n";  // start sub-table row 1 
        echo "<A href=backs/$image.jpg><div align="center"><IMG SRC=images/$image.jpg></A></div>\n"; // insert dynamic image
        echo "\n";  //end sub-table row 1 
        echo "\n";  // start sub-table row 2 
        echo "<br><div align="center">".$row_Recordset1&#1111;'title']."</div>\n";  // insert dynamic text
        echo "\n";  // end sub-table row 2 
        echo "\n";  // sub-table row 3 
        echo "<br><div align="center">".$row_Recordset1&#1111;'format']."</div>\n"; // insert dynamic text
        echo "\n";  // end sub-table row 3 
		echo "</table>\n";  // end sub-table
		echo "</td>\n";  //end master table column
		&#125;
	&#125;

echo "</tr>\n"; // end master table row
echo "</table>\n"; // end master table
			
?>
what i want to do is limit the number of times the loop is run to 4 (therefore limiting the number of returned items to 4). and i want to learn how to set up navigation links below the results (like: next page, previous page, first, last) where these links display the next (prev etc) set of 4 results. how can i do this??
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You need to look into using the LIMIT statement in your SELECT query.

Also try doing a search in this forum on 'prev next' and 'limit' because there's a few variations on this theme out there:
http://www.devnetwork.net/forums/viewto ... ight=limit
being just one.

You might also want to take a look at this FAQ from the devshed forums:
http://forums.devshed.com/showthread.ph ... post154249

Mac
Post Reply