I am currently doing some basic PHP and I am getting products from mysql and displaying each product with the corresponding details in a table.
Currently they are one underneath each other
Product1 Name
Product1 Price
Product1 Description
Product2 Name
Product2 Price
Product2 Description
Now I want to display them in a grid of 3 columns.
which means displaying 3 products side by side, then the 4th product is displayed underneath the 1st product and so on.
$displayAllProducts.=
"
<tr><td>Product Name : </td><td>$productName</td></tr>
<tr><td>Product Price : </td><td>$productPrice</td></tr>
<tr><td>Product Qty : </td><td>$productQty</td></tr>
<tr><td colspan =\"2\"><img src=\"$imagePath\" width = \"100\" height = \"100\"></td><td></td></tr>
<tr><td colspan =\"2\"><a href=\"singleProduct.php?pid=$productID&uid=$uid\">View Product<br/><br/><br/></td><td></td></tr>
";
<table>
<?php
echo $displayAllProducts;
?>
</table>
Without seeing your actual code that loops through your
dbrows, here is a general idea. This will make each$displayAllProductsits own table, nested in the main table<td>‘s