Hello.
I have been following a tutorial, but want to adapt it.
Currently the code below echoes out all of the any occasion cards into a list. I would like them to be echoed into a 2 by 3 formation. 2 down, 3 along.
Struggling to get it to do this, any help appreciated!
<?php
require ("scripts/connect.php");
$dynamicList = "";
$sql = mysql_query("SELECT * FROM products WHERE category = 'anyoccasion'");
$productcount = mysql_num_rows($sql); // count the output amount
if ($productcount > 0) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$productname = $row["productname"];
$price = $row["price"];
$dateadded = strftime("%b %d, %Y", strtotime($row["dateadded"]));
$dynamicList .= '<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td width="17%" valign="top"><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventoryimages/' . $id . '.jpg" alt="' . $productname . '" width="77" height="102" border="1" /></a></td>
<td width="83%" valign="top">' . $productname . '<br />
£' . $price . '<br />
<a href="product.php?id=' . $id . '">View Product Details</a></td>
<td width="17%" valign="top"><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventoryimages/' . $id . '.jpg" alt="' . $productname . '" width="77" height="102" border="1" /></a></td>
<td width="83%" valign="top">' . $productname . '<br />
£' . $price . '<br />
<a href="product.php?id=' . $id . '">View Product Details</a></td>
</tr>
</table>';
}
} else {
$dynamicList = "We have no Birthday Cards listed in our store yet";
}
mysql_close();
?>
<table >
<tr>
<td><?php echo $dynamicList; ?></td>
</tr>
</table>
Thanks Brants91