I want to populate a two column HTML layout from a database using PHP. The records returned will be in date ordered descending, and I want to populate the columns so that the first record goes in column one and the next in column two then back to column one and so on.
I'm working on the theory that I should take the MySQL result and run through it splitting it into two arrays, by putting the first record in the first array and the second in the second array and so on then using those arrays to output to the columns.
The columns are defined as follows;
<div id="leftcol">
</div>
<div id="rightcol">
</div>
EDIT
while($row = mysql_fetch_array($result))
{
$lcol = $lcol + 1;
$vis = 0;
$uri = substr($row[1], 0, strpos($row[1], "&"));
$sql = "SELECT * FROM `readart` WHERE `url`=\"".$uri."\"";
$result2 = mysql_query($sql);
while($row2 = mysql_fetch_assoc($result2))
{
$vis = $row2['visits'];
}
$tit = myTruncate2($row[4], 91);
echo '<div class="newitem">';
echo '<img style="float:left;margin:6px;margin-right:20px;" src="newslogo/'.$row[2].'.png" width="40px" height="40px" />';
echo '<span id="header">'.$tit.'</span><br>';
//echo $row[6];
echo '<span id="date">'.date("D, j F g:i A", $row[6]);
if($vis > 0){echo ' - Viewed '.$vis.' times';}
echo '</span><hr>';
echo '<p id="textbody">';
echo $row[5];
echo '<br><br><a href="recordarticles.php?url='.$row[1].'" target="_blank">Read More</a>';
echo '</p><br></div>';
}