简体   繁体   English

如何使用php在同一个表中列出两个不同产品的详细信息

[英]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 这样自上而下,而不是逐行

index.php 的index.php

while ($row = mysqli_fetch_array($results)) {
    echo '<td><'.$row['name'].'></td>';
}

server.php server.php

$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.

相关问题 如何从Click Bank API和XML中列出产品详细信息? - How to list out product details from click bank API and XML? 如何在php中结合产品详细信息和预订详细信息 - How to combine product details and booking details in php PHP MYSQL。 如何基于另一个表中的2个不同的ID从一个表中检索相同的数据 - PHP MYSQL. How to retrieve the same data from a table based on 2 different ID's in another table 如何在php脚本中比较两个不同的产品价格? - How should I compare two different product price in php script? 如何在同一页面上获取不同的表 - How to get different table's on same page 如何根据同一SELECT中不同的id从表中获取两个值 - How to get two values from table based on different id's in same SELECT 如何在同一表格的两个不同列中查找和显示相似单词的数量(MySql,PHP) - How to find and show number of similar words in two different column within same table(MySql,PHP) 同一页中两个不同网址的标头(PHP) - Two headers for different url's in the same page (PHP) 如何使来自同一表的两个$ db-&gt; query具有按列彼此独立地位于一个php页面中的两个不同ORDER? - How to make two $db->query from the same table with two different ORDER by column that each other stand independenty in one php page? PHP MYSQL 如何使用当前表的记录 ID 显示和列出两个表中的所有记录? - PHP MYSQL how to show and list all records from two tables using current table's record id?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM