I have been trying to find a way to split my content from a database into two divs but for some reason I am getting multple divs and its causes a layout issue.
This is what I have now;
Code: Select all
<?php
echo "<div id=\"ccol-two\">";
$sql = mysql_query("select * from categories");
while ($row = mysql_fetch_array($sql))
{
$i=1;
$id = $row[0];
$name = $row[1];
echo "<br /><span class=\"bold\">$name</span><br/>";
echo "<span class=\"bold\">*Course Code / Course Name</span> <br />";
$innersql = mysql_query("select * from classes where categoryid = '$id'");
$num_rows = mysql_num_rows($innersql);
$percol = $num_rows/2;
while ($row2 = mysql_fetch_assoc($innersql))
{
$name = $row2['coursename'];
$link = $row2['link'];
echo "<a href = \"$link\" target=\"_blank\">$name</a> <br />";
}
if ($i > $percol)
{
echo "</div><div id=\"ccol-one\">";
}
$i++;
}
echo "</div>";
?>
Any help would be really appreciated. Thanks.