Is there a better way to write this code? What it does is create a {X}x{X} table but I want to create variables to change the number of <td>s and <tr>s depending on the number of results. This example only works properly if the table is 4x4. Any help would be appreciated.
Thanks in advance...
<?
//database connection script
$position = "1";
echo ("<table border='1'>");
echo ("<tr>");
$db_ID = "SELECT ID
FROM db_table
LIMIT 16 ";
$db_result_ID = mysql_query($db_ID);
while ($db_output_ID = mysql_fetch_array($db_result_ID))
{
extract($db_output_ID);
if ($position == "1" OR $position == "5" OR $position == "9" OR $position == "13") { echo ("<tr>"); }
echo ("<td>");
echo ("{$position}: {$storyID}");
echo ("</td>");
if ($position == "4" OR $position == "8" OR $position == "12" OR $position == "16") { echo ("</tr>"); }
$position++;
}
echo ("</table>");
?>