该程序正在新行中打印每个数据。我希望它在一行中打印 3 个数据,然后更改行并在新行中打印其他 3 个数据。我曾尝试使用 for 循环,但它没有给我所需的输出。请告诉如何在这个程序中做到这一点
<table width="550" border="0" align="center" cellpadding="2" cellspacing="2" bordercolor="#000000">
<tr>
<th align= "left"><a href="#"><table width="160" border="0" align="center" cellpadding="0" cellspacing="0">
<?php
/*Inner Page- Products exists in Certain Category!!
======================================================*/
$sub2_query = "select * from sub_categories where category_id=$category_id ";
$sub2_query_run = mysql_query($sub2_query);
while ($sub2_query_fetch = mysql_fetch_array($sub2_query_run))
{
$sub2_category_id = $sub2_query_fetch['sub_category_id'];
$inner_query = "select * from products inner join product_description
on products.product_id= product_description.product_id
where sub_category_id= $sub2_category_id";
if($inner_query_run = mysql_query ($inner_query))
{
while($inner_query_fetch = mysql_fetch_array($inner_query_run))
{
$product_id = $inner_query_fetch['product_id'];
$inner_image_query = "select * from product_images
where product_id=$product_id";
$inner_image_query_run = mysql_query($inner_image_query);
//PRINTING imagesss
echo "</th><tr><td align='center'>";
echo "<div id='border'>";
echo "<td>";
echo "<a href='index_product_details2.php?product_id=$product_id' >";
$inner_image_query_fetch = mysql_fetch_array($inner_image_query_run);
echo "<img src=http://localhost/cms/".
$inner_image_query_fetch['images']." height='150' width='150' alt=\"\" />
</td>
</tr>
</div>";
?>
<tr>
<td align="center">
<?php
//PRINTING NAMES
print_r($inner_query_fetch['name']);
echo "<br> Price: ";
print_r($inner_query_fetch['actual_price']);
echo "</a>";
echo "<br><br>";
}
}else{
echo mysql_error();
}
}
}
?>
</td>
</tr>
</table>