波兰钻石 信息
mysql_connect("localhost","root",""); mysql_select_db("basic");
$order = "select * from polish "; $result=mysql_query($order);
$a="select sum(total) from polish"; $b=mysql_query($a);
?>
<?php echo "Polish Diamonds Information: ";
echo "<a href='home.html'>Go to main page
<br><br>";
?>
<table border="1" style="width:50%">
<tr>
<th><b>ID</b></th>
<th><b> Name</b></th>
<th> <b>Selection</b><br>(40000)</th>
<th><b>Super Deluxe<br>(35000)</b></th>
<th><b>1<br>(30000)</b></th>
<th><b>2<br>(25000)</b></th>
<th><b>3<br>(20000)</b></th>
<th><b>4<br>(10000)</b></th>
<th><b>Total Payment</b></th>
<th><b>Days</b></th>
</tr>
<?php while($row = mysql_fetch_array($result) ) {
echo "<tr>
<td>".$row['id']."</td>
<td>".$row['name']."</td>
<td>".$row['c_sel']."</td>
<td>".$row['c_sdel']."</td>
<td>".$row['c_1']."</td>
<td>".$row['c_2']."</td>
<td>".$row['c_3']."</td>
<td>".$row['c_4']."</td>
<td>".$row['total']."</td>
<td>".$row['day']."</td>
</tr>"; }
?> </html>
答案 0 :(得分:0)
试试这个循环
$sum_val=0;
while($row = mysql_fetch_array($result) ) {
echo "<tr>
<td>".$row['id']."</td>
<td>".$row['name']."</td>
<td>".$row['c_sel']."</td>
<td>".$row['c_sdel']."</td>
<td>".$row['c_1']."</td>
<td>".$row['c_2']."</td>
<td>".$row['c_3']."</td>
<td>".$row['c_4']."</td>
<td>".$row['total']."</td>
<td>".$row['day']."</td>
</tr>";
$sum_val+=$row['total'];
}
echo"Last column total= $sum_val";
答案 1 :(得分:0)
$order = "select *, sum(c_sel+c_sdel+c_1+c_2+c_3+c_4) as total from polish GROUP BY id "; $result=mysql_query($order);