簡體   English   中英

從多個 SQL 表創建 PHP 表

[英]PHP table creation from multiple SQL tables

我正在嘗試從 SQL 的多個表創建 PHP 表。 我無法在一行中打印多個數據庫表中的記錄信息。

代碼:

 while($row = mysql_fetch_array($info)){

   foreach($field as $query){
     echo "<td>" . $row[$query] . "</td>" ;     

   }

echo "<tr>";
 }



while($row = mysql_fetch_array($standing)){

foreach($field as $query){
  echo "<td>" . $row[$query] . "</td>" ;
  }

}

例如我的登錄是NT882,我在“info”和“standing”表中有信息,這段代碼打印“info”表中的所有信息,然后從下一行打印“standing”表中的信息。

我想打印“信息”表中的前 4 列,以及該特定行中“站立”表中的后 2 列。

如果是的話,關於從 PHP 生成 HTML 表。 然后試試這個方法。

echo "<table>";
while($row = mysql_fetch_array($info)){
   echo "<tr>"; 
   //get fields to $fields
   foreach($field as $query){
     echo "<td>" . $row[$query] . "</td>" ;     
   }
   echo "</tr>";
}
echo "</table>";


echo "<table>";
while($row = mysql_fetch_array($standing)){
    echo "<tr>";
   //get fields to $fields
    foreach($field as $query){
        echo "<td>" . $row[$query] . "</td>" ;
    }
   echo "</tr>";
}
echo "</table>";

暫無
暫無

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

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