我正在将一个mysqli查询输出到一个表格很好但我需要回显页面其他部分的某些字段并且似乎已经撞墙了?使用以下代码,我能够将所有数据输出到表中,但也希望输出d.total&如果可能,i.date_paid值到页面的其他部分?
<?php
$host = "localhost";
$user = "root";
$pass = "mypassword";
$db_name = "mydbname";
//create connection
$connection = mysqli_connect($host, $user, $pass, $db_name);
//test if connection failed
if(mysqli_connect_errno()){
die("connection failed: "
. mysqli_connect_error()
. " (" . mysqli_connect_errno()
. ")");
}
//get results from database
$result = mysqli_query($connection,"SELECT
d.invoice_id,
i.date_paid,
i.adviser,
d.client,
d.payment_type,
d.total
FROM
tbl_invoice i
INNER JOIN tbl_invoice_data d ON d.invoice_id = i.id LIMIT 10");
$all_property = array(); //declare an array for saving property
//showing property
echo '<table class="data-table">
<tr class="data-heading">'; //initialize table tag
while ($property = mysqli_fetch_field($result)) {
echo '<td>' . $property->name . '</td>'; //get field name for header
array_push($all_property, $property->name); //save those to array
}
echo '</tr>'; //end tr tag
//showing all data
while ($row = mysqli_fetch_array($result)) {
echo "<tr>";
foreach ($all_property as $item) {
echo '<td>' . $row[$item] . '</td>'; //get items using property value
}
echo '</tr>';
}
echo "</table>";
?>
非常感谢任何想法