我有 MAMP(本地托管 SQL、WEB 等服务器),数据库名称是:NKTDEBITS,表名称是:Insurance,表上的列是 STATECOV。我知道我对此很接近,但仍然在应该产生总数的领域中得到一个黑色,有人知道吗?
<?php
$con=mysqli_connect("localhost","root","root","KNTDebits");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM Insurance");
$result2 = mysqli_query($con,"SELECT * FROM Office");
$result3 = mysqli_query($con,"SELECT * FROM RichmondLocation");
$result4 = mysqli_query($con,"SELECT * FROM DanvilleLocation");
$result5 = mysql_query('SELECT SUM(STATECOV) AS STATECOV_sum FROM Insurance');
echo "<table border='1'>
<tr>
<th>Truck Number</th>
<th>VIN</th>
<th>Make</th>
<th>Model</th>
<th>State Coverage</th>
<th>Comprehinsive Coverage</th>
<th>Property Damage/th>
<th>Personal Injury</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['TNUM'] . "</td>";
echo "<td>" . $row['VIN'] . "</td>";
echo "<td>" . $row['MAKE'] . "</td>";
echo "<td>" . $row['MODEL'] . "</td>";
echo "<td>" . $row['STATECOV'] . "</td>";
echo "<td>" . $row['COMPRE'] . "</td>";
echo "<td>" . $row['PROPDMG'] . "</td>";
echo "<td>" . $row['PRSINJ'] . "</td>";
echo "</tr>";
}
echo "</table>";
//Table 2 Start
str_repeat(' ', 5); // adds 5 spaces
echo "<table border='5'>
<tr>
<th>Richmond</th>
<th>Date</th>
<th>Payment</th>
<th>Payer</th>
</tr>";
while($row3 = mysqli_fetch_array($result3))
{
echo "<tr>";
echo "<td>" . $row3[''] . "</td>";
echo "<td>" . $row3['DATE'] . "</td>";
echo "<td>" . $row3['PAYMENT'] . "</td>";
echo "<td>" . $row3['PAYER'] . "</td>";
echo "</tr>";
}
echo "</table>";
//Table 4 Start
str_repeat(' ', 5); // adds 5 spaces
echo "<table border='5'>
<tr>
<th>Danville</th>
<th>Date</th>
<th>Payment</th>
<th>Payer</th>
</tr>";
while($row4 = mysqli_fetch_array($result4))
{
echo "<tr>";
echo "<td>" . $row4[''] . "</td>";
echo "<td>" . $row4['DATE'] . "</td>";
echo "<td>" . $row4['PAYMENT'] . "</td>";
echo "<td>" . $sum . "</td>";
echo "</tr>";
}
echo "</table>";
//Table 5 Start
echo "<table border='5'>
<tr>
<th>Total</th>
</tr>";
$result = mysql_query('SELECT SUM(STATECOV) AS value_sum FROM Insurance');
$row = mysql_fetch_assoc($result);
$sum = $row['value_sum'];
while($row = mysql_fetch_assoc($result));
{
echo "<tr>";
echo "<td>" . $sum . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>