Page 1 of 1

Split MySQL result into groups of 4

Posted: Thu May 28, 2009 11:11 am
by ghogilee
Maybe today my brain isn't much of use :) but I need help to split mysql result into groups of 4 like

result1
result2
result3
result4
(and here goes some delimiter like <hr/> or something like that..)
result5
result6
result7
result8
(delimiter again)
.. etc to the end of the mysql array...

Re: Split MySQL result into groups of 4

Posted: Thu May 28, 2009 3:03 pm
by Darhazer

Code: Select all

 
$count = mysql_num_rows($result);
for ($i = 0; i < $count; $i++) {
   if ($i != 0 && $i % 4 == 0) echo '<hr>';
   // the other code
}

Re: Split MySQL result into groups of 4

Posted: Thu May 28, 2009 4:51 pm
by ghogilee
Great!!! Thank you very much! :drunk: