簡體   English   中英

如何在 html php mysql 表中顯示更多結果?

[英]How can I show more results in a html php mysql table?

我正在嘗試使用數據庫中的數據制作 html 表,但是當我編寫 echo 時,它只顯示了一個結果。 如何回顯所有元素?

$sql = "SELECT * FROM app_spot where company_id='$company_id'";

$result = mysqli_query($db, $sql);

if (mysqli_num_rows($result) > 0) {

  while($row = mysqli_fetch_array($result)) {
   $spot_id = $row["id"];
   $spot_name = $row["spot_name"];
   $store_location = $row["store_location"];
   $spot_budget = $row["spot_budget"];
   $spot_status = $row["spot_status"];

  }

  $spotcount = mysqli_num_rows($result);


} else {
    echo "0 results";
} 

while循環中回顯表行。

if (mysqli_num_rows($result) > 0) {
    echo "<table><tr><th>ID</th><th>Name</th><th>Location</th><th>Budget</th><th>Status</th></tr>";
    while($row = mysqli_fetch_array($result)) {
        $spot_id = $row["id"];
        $spot_name = $row["spot_name"];
        $store_location = $row["store_location"];
        $spot_budget = $row["spot_budget"];
        $spot_status = $row["spot_status"];
        echo "<tr><td>$spot_id</td><td>$spot_name</td><td>$store_location</td><td>$spot_budget</td><td>$spot_status</td></tr>";
    }
    echo "</table>";
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM