art15 Posted June 29, 2009 Share Posted June 29, 2009 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 More sharing options...
cunoodle2 Posted June 29, 2009 Share Posted June 29, 2009 You want just 4 items shown? If so can you add a "LIMIT 4" to the end of your query? Or is there more to the problem than that? Explain in a little more detail and I'll whip an solution for you. Oh and please use the "code" tags in the future. Link to comment https://forums.phpfreaks.com/topic/164044-loop-the-output-of-mysql-result/#findComment-865418 Share on other sites More sharing options...
art15 Posted June 29, 2009 Author Share Posted June 29, 2009 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 Link to comment https://forums.phpfreaks.com/topic/164044-loop-the-output-of-mysql-result/#findComment-865439 Share on other sites More sharing options...
Twister1004 Posted June 29, 2009 Share Posted June 29, 2009 I believe you're wanting to do pagination. Link to comment https://forums.phpfreaks.com/topic/164044-loop-the-output-of-mysql-result/#findComment-865443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.