[英]PHP table creation from multiple SQL tables
I am trying to create PHP table from multiple table from SQL.我正在尝试从 SQL 的多个表创建 PHP 表。 I am unable to print the information for a record from multiple database table in one row.我无法在一行中打印多个数据库表中的记录信息。
Code:代码:
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>" ;
}
}
Example my login is NT882, and I have information in "info" and "standing" table, this code prints all the information from "info" table, and then from next line prints the information from "standing" table.例如我的登录是NT882,我在“info”和“standing”表中有信息,这段代码打印“info”表中的所有信息,然后从下一行打印“standing”表中的信息。
I want to print first 4 columns from "info" table, and next 2 columns from "standing" table in that particular row.我想打印“信息”表中的前 4 列,以及该特定行中“站立”表中的后 2 列。
If its, about HTML Table generation from PHP.如果是的话,关于从 PHP 生成 HTML 表。 then try this way.然后试试这个方法。
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.