Mysqli Output to a table
PHP Snippet 1:
$requiredRows= 18;
$rows = $result->num_rows ;
$columns = ceil($rows/$requiredRows);
$i = 0;
while($row = $result->fetch_assoc())
{
if ($i == 0) {
echo "<table><tr><td>";
}
elseif ($i % $columns) {// <> 0
echo "</td>\n";
echo "<td>\n";
}else{//$i % $columns == 0
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>\n";
}
echo $row['country'];
$i++;
}