我尝试将产品详细信息显示为2列。
目前,我的下面的PHP显示为单个列。有人可以帮忙吗?感谢
品牌A品牌B
品牌C品牌D
不
品牌A
品牌B
品牌C
品牌D
<?php
$count = 0;
while($record = mysql_fetch_array($results)){
$id = $record["prod_id"];
$brand = $record["prod_brand"];
$name = $record ["prod_name"];
$nameC = $record ["prod_name_c"];
$price = $record ["prod_price"];
if($count % 2 <> 0) {
extract($record);
echo '<td class="itemHotDesc" id="bfTable3" valign="top"><a href="productDetail.php?id='.$id.'"><img src="admin/img/' . $id . '.jpg" class="itemImgborder" /></td>';
echo '</tr>';
echo '<tr>';
echo '<td class="itemHotDesc" align="center">';
echo $brand;
echo '</br>';
echo $name;
echo '</br>';
echo $nameC;
echo '</br>';
echo 'Special: US$'.$price;
echo '</td>';
echo '</tr>';
echo '<tr>';
echo "<td> </td>";
echo '</tr>';
}
else
{
echo '<td class="itemHotDesc" id="bfTable3" valign="top"><a href="productDetail.php?id='.$id.'"><img src="admin/img/' . $id . '.jpg" class="itemImgborder" /></td>';
echo '</tr>';
echo '<tr>';
echo '<td class="itemHotDesc" align="center">';
echo $brand;
echo '</br>';
echo $name;
echo '</br>';
echo $nameC;
echo '</br>';
echo 'Speical: US$'.$price;
echo '</td>';
echo '</tr>';
echo '<tr>';
echo "<td> </td>";
echo '</tr>';
}
$count++;
}
&GT?;
答案 0 :(得分:0)
您的问题与PHP无关,但与HTML有关。
要拥有包含多个列的表,您需要每行拥有一个<table>
元素和一个<tr>
元素。在每个<tr>
中,您需要为每个列设置一个<td>
元素。
如果每个<td>
中只有一个<tr>
,则不会有多个列。
以下是包含多列的表的示例:
<table>
<tr>
<td>This is row 1, Column 1</td>
<td>This is row 1, Column 2</td>
<td>This is row 1, Column 3</td>
</tr>
<tr>
<td>This is row 2, Column 1</td>
<td>This is row 2, Column 2</td>
<td>This is row 2, Column 3</td>
</tr>
<tr>
<td>This is row 3, Column 1</td>
<td>This is row 3, Column 2</td>
<td>This is row 3, Column 3</td>
</tr>
</table>
这应该给你类似
的东西-------------------------------------------------------------------------------
| This is row 1, Column 1 | This is row 1, Column 2 | This is row 1, Column 3 |
|-------------------------|-------------------------|-------------------------|
| This is row 2, Column 1 | This is row 2, Column 2 | This is row 2, Column 3 |
|-------------------------|-------------------------|-------------------------|
| This is row 3, Column 1 | This is row 3, Column 2 | This is row 2, Column 3 |
-------------------------------------------------------------------------------