Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rowspan在php中的嵌套while循环中不起作用_Php_Html - Fatal编程技术网

Rowspan在php中的嵌套while循环中不起作用

Rowspan在php中的嵌套while循环中不起作用,php,html,Php,Html,这里的编码事务是我的表名,我使用mysql数据库。 想做什么: 将“全部合计”的所有值相加 在“总计”中显示总和值 “总计”应为$q 我尝试过划行,但我不知道为什么td会重复,我也不知道如何将“all TOTAL”的所有值相加 //我想要这样的输出 COUNTER |SELLER NAME|TRANSACTION DETAILS | All TOTAL | GRAND TOTAL ---------------------------------------------------

这里的编码事务是我的表名,我使用mysql数据库。 想做什么:

  • 将“全部合计”的所有值相加
  • 在“总计”中显示总和值
  • “总计”应为$q
  • 我尝试过划行,但我不知道为什么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>";
    
    $all=“从事务中选择*”;
    $resultall=mysql\u查询($all,$con);
    $q=mysql\u num\u行($resultall);
    $query=“从交易中选择不同的客户名称”;
    $result=mysql\u查询($query,$con);
    $names=array();
    回声“;
    echo“客户名称卖家名称交易明细全部合计合计”;
    while($row=mysql\u fetch\u数组($result))
    {
    $query2=“从客户名称为“$row[0]”的交易中选择*”;
    $result2=mysql\u查询($query2,$con);
    $n=mysql\u num\u行($result2);
    回显“.”行[0];
    $s=0;
    $i=1;
    $query1=“选择seler_name,customer Total FROM transaction,其中customer_name='$row[0]'”;
    $result1=mysql\u查询($query1,$con);
    $snames=array();
    $query3=“从客户名称为“$row[0]”的交易中选择客户总数”;
    $result3=mysql\u查询($query3,$con);
    while($row=mysql\u fetch\u数组($result3))
    {
    $s=$s+$row[0];
    }
    而($row=mysql\u fetch\u数组($result1))
    {
    如果($i==1)
    回显“$row[0]”.$row[1]”.“$s.”aaa;
    其他的
    回显“$行[0]”.$行[1]”;
    $i++;
    }
    回声“;
    }
    回声“;
    
    您没有正确地关闭
    s。您可能希望将代码的格式设置得更好一些。。我的眼睛流血了Gare你确定要使用rowspan而不是colspan吗?@karthikr closing td标记在html4/5中是可选的。它们在xhtml中是必需的。但是anuj没有指出他们正在使用的DTD,因此他们可能希望考虑您的建议。是的,我想使用rowspan。