[英]How to list out two different product's details at the same table with php
I only can list out all the data row by row but I want to list out those 2 products like this from top to bottom, not row by row within 我只能列出的行中的所有数据行,但我想列出了这些产品2 这样自上而下,而不是逐行内
while ($row = mysqli_fetch_array($results)) {
echo '<td><'.$row['name'].'></td>';
}
$db = mysqli_connect('localhost','root','','crud');
$results = mysqli_query($db, "SELECT * FROM info");
If I really understand, you want each product to be in a different line. 如果我真的明白,你希望每个产品都在不同的路线上。 If yes, you could create new rows directly inside your loop like this 如果是,您可以像这样直接在循环内创建新行
while ($row = mysqli_fetch_array($results)) {
echo '<tr><td>'.$row['name'].'</td></tr>';
}
<?php
while($row = mysqli_fetch_array($results)){
$detail_row.="<td>" . $row['items'] . "</td>";
$category_row.="<td>" . $row['items'] . "</td>";
}
?>
<table>
<tr>
<td>Details</td>
<?php echo $detail_row; ?>
</tr>
<tr>
<td>Categories</td>
<?php echo $category_row; ?>
</tr>
</table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.