New line after x amount of records(Solved)

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
jefffan24
Forum Commoner
Posts: 72
Joined: Mon Nov 02, 2009 8:18 am

New line after x amount of records(Solved)

Post by jefffan24 »

I want to create a link break (or if in a table create a new row) after x amount of records.

I would be using a while loop like:

$sql = "SELECT * FROM blah";
$query = mysql_query($sql);
while($result = mysql_fetch_assoc($query)){
echo $result['name'];
//After every 3rd record create a new line
}
jefffan24
Forum Commoner
Posts: 72
Joined: Mon Nov 02, 2009 8:18 am

Re: New line after x amount of records(Solved)

Post by jefffan24 »

I got it thanks I did

$count = 0;
while(blah blah){
if($count == 2){
echo "<br />";
$count = 0;
}

blah blah

}

It works :p thanks all.
Post Reply