Forum Moderators: coopster

Message Too Old, No Replies

Select and ouput exactly 5 results from db

and then output results 6-10

         

coolo

8:02 am on Feb 26, 2004 (gmt 0)

10+ Year Member



Hello, it's me asking for help again.

Anyhow, I'm trying to display a bunch of pictures in rows with 5 pictures per row. The filenames of the pictures are all stored in a MySQL database and the actual files are stored on the server. So, I know how to return and output all of the records from a MySQL table using a while statement. However, I need to only output five of them, insert a break in the HTML to start a new line, and then output five more and another break, and then do it again until there are no more pictures left. Anyone have any ideas? I was thinking of a for loop iterating 5 times to output the first five image files, but how could I make the for loop happen a second and third time?

justageek

12:05 pm on Feb 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could just ad a counter in the while loop.

$i = 1;
while(getting_data){
if($i<=5){
echo "data_on_same_line";
$i++;
}else{
echo "new_line";
echo "data_on_new_line";
$i=1;
}
}

JAG

coopster

1:32 pm on Feb 26, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



another option... [webmasterworld.com]