Split records into two columns

mysql, php

Solution

Just find where the "middle" is and output the end tag of the div tag and the start tag of the second div:

<? 
$rowcount = mysql_num_rows($recordset);
echo "<div id='div1'>";
$i = 0;
while ($d = mysql_fetch_object($recordset)) {
  echo $d->somefield;
  $i++;

  if ($i == floor($rowcount / 2)) {
      //we have reached the mid-point, let's close the first DIV
      echo "</div><div id='div2'>";
  }
}
echo "</div>";
?>

Problem

I have a "student" table, having around 5,000 records, in my DB. I want to display those records in two divs. How do I do that without executing the query twice; only using a single query? display example http://www.freeimagehosting.net/uploads/f1c6bb41eb.gif

Original source