Jump to content

Loop the output of mysql result


art15

Recommended Posts

Hi,

 

When I fetch the result from mysql, it gives me the result of all the rows. what I want is to group the output of mysql into group of 4.

eg output of $new into a group of 4;

 

$sSQL="select something from table something between a and b;";

$result=mysql_query($sSQL) or die('Error, cannot retrieve the information');

while($rs=mysql_fetch_row($result)){

echo $new=$rs[0]."<br>";

}

 

Thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/164044-loop-the-output-of-mysql-result/
Share on other sites

Thanks for your reply.

 

I just don't want to LIMIT it to 4. When the output result has 40 rows. I want to split it into chunks of 4. so instead of one variable say $total displaying all the 40 rows. I want $total1 to be first group having 4 values, $total2 having next 4 and so on.. I belive it should be an array.

 

Thanks

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.