php script error 3 tables per row the first only shows 2
Posted: Thu Jan 09, 2014 12:58 am
Hi, am having trouble with a script to put 3 fields in a row it only shows 2 in the first row and then it shows 3 as it suppose to, the code is:
Any help will be appreciated, thanks!
Code: Select all
<table><tr>
<?php
mysql_connect("localhost", "user","password") or die ("error");
mysql_select_db("database") or die ("error");
$result = mysql_query ("select * from table order by RAND()") or die (mysql_error());
$i = 0;
while ($row = mysql_fetch_array($result)) : $i ++;
if($i==3) {
echo "</tr><tr>";
$i = 0;
}
?>
<td>
<table><tr><td>
TABLE EXAMPLE
</td></tr></table>
</td>
<?php endwhile; ?>
</tr></table>