I`m displaying a certain number of result from mysql database.
My problem come when i need to display for example 4 result in first row,the other 4 in the second row and so on.
the code below displays all the results but each in its own row

<?php
include"config.php";
$query="SELECT *FROM profcomment WHERE rece_user='$user'";
$result=mysql_query($query);
if($result){

while($row=mysql_fetch_array($result)){
$id=$row['id'];
$date=$row['date'];

$sentby=$row['sender'];
$comment=$row[comment];

echo"sent by: $sentby Comment:$comment  date sent:$date</br>";
}
}
?>

any one who knows what i should to make it display a certain number of results in one row and so ON??
ur help will be appreciated.

One way to do this would be to include an if statement and a counter for example,

$counter=0
while(sql_statement) {
$id=$row['id'];
$date=$row['date'];

$sentby=$row['sender'];
$comment=$row[comment];

if($counter==4) {
echo "<br />";

// reset the counter
$counter = 0;
}
echo"sent by: $sentby Comment:$comment  date sent:$date";
$counter++;
}
This question has already been answered. Start a new discussion instead.