这里的编码事务是我的表名,我使用的是mysql数据库。 想做:
我曾尝试过rowspan,但我不知道为什么td会重复,而且我不知道如何总结'All TOTAL'的所有值
//我想要像这样的输出
COUNTER |SELLER NAME|TRANSACTION DETAILS | All TOTAL | GRAND TOTAL
---------------------------------------------------------------------------------------
| a.... | 20 | 50 | |
Counter1| a.... | 30 | | 90 |
|-----------|----|----------------| |
| c.... | 40 | 40 | |
--------|-----------|----|----------------|----------------| 180
| a.... | 20 | 50 | |
Counter2| a.... | 30 | | 90 |
|-----------|----|----------------| |
| c.... | 40 | 40 | |
---------------------------------------------------------------------------------------
请帮忙。
$all="SELECT * FROM transaction";
$resultall = mysql_query($all, $con);
$q=mysql_num_rows($resultall);
$query = "SELECT distinct customer_name FROM transaction";
$result = mysql_query($query, $con);
$names = array();
echo"<table border=1>";
echo"<tr><th>CUSTOMER NAME<th>SELLER NAME<th>TRANSACTION DETAILS<th>All TOTAL<th>GRAND TOTAL</tr>";
while ($row = mysql_fetch_array($result))
{
$query2 = "SELECT * FROM transaction where customer_name='$row[0]'";
$result2 = mysql_query($query2, $con);
$n=mysql_num_rows($result2);
echo"<tr><td rowspan=$n >". $row[0];
$s=0;
$i=1;
$query1 = "SELECT seler_name,customertotal FROM transaction where customer_name='$row[0]'";
$result1 = mysql_query($query1, $con);
$snames = array();
$query3 = "SELECT customertotal FROM transaction where customer_name='$row[0]'";
$result3 = mysql_query($query3, $con);
while ($row = mysql_fetch_array($result3))
{
$s=$s+$row[0];
}
while ($row = mysql_fetch_array($result1))
{
if($i==1)
echo "<td>".$row[0]."<td>".$row[1]."<td rowspan=$n>$s"."<td rowspan='$q'>aaa<tr>";
else
echo "<td>".$row[0]."<td>".$row[1]."<tr>";
$i++;
}
echo"</tr>";
}
echo"</table>";