I am trying to dynamically display a list of products in two columns (side by side) and I am not sure how to do it with tables
Here is my code that displays all products in one column
$productCount = sqlsrv_num_rows($stmt); // count the output amount
$columncount = 0;
$dynamicList = '<table width="744" border="0" cellpadding="6"><tr>';
while($row = sqlsrv_fetch_array($stmt)){
$id = $row["productID"];
$product_name = $row["product_name"];
$product_price = $row["product_price"];
$dynamicList .= '<td width="135"><a href="product_details.php?productID=' . $id . '"><img src="images/products/Small/Men/' . $id . '.jpg" alt="' . $product_name . '" width="129" height="169" border="0"></a></td>
<td width="593" valign="top">' . $product_name . '<br>
£' . $product_price . '<br>
<a href="product_details.php?productID=' . $id . '">View Product Details</a></td>';
if($columncount == 2){
$dynamicList .= '</tr><tr>';
$columncount = 0;
}else
$columncount++;
}
$dynamicList .= '</tr></table>';
<?php echo $dynamicList; ?><br>
How do I get my products to display in two columns instead of one?
Updated my post with the working solution