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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.