本文介绍了Php子总数和所有总数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<html>   
<head>    
</head>  
<body>  
<?php
	include('connection.php');
	$sql = mysqli_query($connection,"SELECT COALESCE(Customer.CustomerID, 'Sub Total') AS CustomerID, 
									Customer.CusName,  
									CusGroup.groupId, 
									Customer.CreditAllowed,
									SUM(Customer.CreditAllowed) AS total
									FROM Customer INNER JOIN CusGroup ON Customer.GroupID=CusGroup.groupId 
									GROUP BY CusGroup.groupId ,Customer.CustomerID with rollup");
	echo '<table border="1" align="center" width="80%">
			<thead>
				<tr>
					<td>CustomerId</td>
					<td>CustomerName</td>
					<td>Group Id</td>
					<td>CreditLimit</td>
					<td>Total</td>
				</tr>
			</thead>
			<tbody>';
	$total = 0;
	while($row=mysqli_fetch_array($sql,MYSQLI_ASSOC)){
		echo '<tr>
				<td>'.$row['CustomerID'].'</td>
				<td>'.$row['CusName'].'</td>
				<td>'.$row['groupId'].'</td>
				<td>'.$row['CreditAllowed'].'</td>
				<td>'.number_format($row['total']).'</td>
			  </tr>';
		$total +=$row['total'];
	}
		'</tbody>
		</table>';	
?> 
</body>  
</html>  





我的尝试:





What I have tried:

i want sub total and all the totals of the sub total.but in sub total row i get unnecessary data allso plz check this and help me im new to programming.

推荐答案




这篇关于Php子总数和所有总数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 21:27