Hi, I am trying to display fields from a MQSQL database into a html table.
here is my code
[php]
<?php
$catagory=$_GET[“q”];
$con = mysql_connect(“localhost”,“cl49-XXX”,“XXX”);
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}
mysql_select_db(“cl49-XXX”, $con)or die( “Unable to select database”);
$result=mysql_query("SELECT * FROM products WHERE catagory = ‘$catagory’ ")or die('You need enter a catagory ’ );
for ($i = 0; $i < mysql_num_rows($result); $i++)
{
$row = mysql_fetch_array($result);
$prodname = $row['prodname'];
$prodID = $row['prodID'];
if ($i % 5 == 0 || $i == 0) {
echo "<tr>";
}
echo "
<td>
<b>$prodname </b><br />
Product ID: $prodID<br />
<img src='userpics/$prodID.jpg' height='200' width='200'>
</td>";
if ($i % 3 == 0 || $i == (mysql_num_rows($result)-1)) {
echo "</tr>";
}
}
?>
[/php]
I am wanting to know how i can limit the table to 3 columns??
Basically 3 items per row…