Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Dividir registros em duas colunas


Basta encontrar onde está o "meio" e gerar a tag final da tag div e a tag inicial da segunda 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>";
?>