Select the records from the table using the query and put it in an indexed array.
After this use the PHP array function array_slice
The array_slice() function returns selected parts of an array.
example:
<?php
$a=array(0=>"Dog",1=>"Cat",2=>"Horse",3=>"Bird");
print_r(array_slice($a,1,2));
?>
The output of the code above will be:
Array ( [0] => Cat [1] => Horse )
With string keys:
<?php
$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse","d"=>"Bird");
print_r(array_slice($a,1,2));
?>
The output of the code above will be:
Array ( [b] => Cat [c] => Horse )
By this way we can split the needed results array like this
Let $a as our results array
$firstrow= array_slice($a,0,1);
$secondrow= array_slice($a,1,3);
$thirdrow= array_slice($a,4,4);
$fourthrow= array_slice($a,-1,3);