製品のリストを 2 つの列 (横に並べて) で動的に表示しようとしていますが、テーブルでそれを行う方法がわかりません
すべての製品を 1 つの列に表示するコードを次に示します。
$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>
商品を 1 列ではなく 2 列で表示するにはどうすればよいですか?
実用的なソリューションで私の投稿を更新しました