Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.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
Php 加入2个表以添加另一个表sales total_Php - Fatal编程技术网

Php 加入2个表以添加另一个表sales total

Php 加入2个表以添加另一个表sales total,php,Php,如何在我的表格中添加采购项目的总成本? 我想在销售总额中添加另一行,即向供应商购买特定商品的用户 销售明细表 销售表 我想添加总价的地方的示例照片 这将是一个很大的帮助,谢谢你们 这是我的php文件 <h1 class="page-header">Product Sales Report</h1></center> </div> </div> <div class="row">

如何在我的表格中添加采购项目的总成本? 我想在销售总额中添加另一行,即向供应商购买特定商品的用户

销售明细表

销售表

我想添加总价的地方的示例照片 这将是一个很大的帮助,谢谢你们

这是我的php文件

 <h1 class="page-header">Product Sales Report</h1></center>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <center>
 <form action="total_sales.php" method="post">
  From: <input type="text" class="datepicker" placeholder="E.G.(2018-01-14)" name="dayfrom" required pattern="[0-9]{4}+[0-9]+[0-9]"> To: <input type="text" class="datepicker" placeholder="E.G.(2018-02-11)" name="dayto" required pattern="[0-9]{4}+[0-9]+[0-9]">
  <input type="submit" value="Show Sales" name="salesbtn" ></form></center>

            <table width="100%" class="table table-striped table-bordered table-hover" id="prodTable">
                <thead>
                    <tr>
                        <th class="hidden"></th>
                        <th>Purchase Date</th>
                        <th>Customer</th>
                        <th>Product Name</th>
                        <th>Quantity</th>
                    </tr>
                </thead>
                <tbody>
                <?php
                    $sq=mysqli_query($conn,"select * from sales_detail left join product on product.productid=sales_detail.productid left join sales on sales.salesid=sales_detail.salesid left join customer on sales.userid=customer.userid where product.supplierid='".$_SESSION['id']."' order by sales.sales_date desc");;
                    while($sqrow=mysqli_fetch_array($sq)){

                    ?>
                        <tr>
                            <td class="hidden"></td>
                            <td><?php echo date('M d, Y h:i A',strtotime($sqrow['sales_date'])); ?></td>
                            <td><?php echo $sqrow['customer_name']; ?></td>
                            <td><?php echo $sqrow['product_name']; ?></td>
                            <td><?php echo $sqrow['sales_qty']; ?></td>
                        </tr>
                    <?php
                    }
                ?>
                </tbody>
            </table>
        </div>
    </div>

我在while循环中添加了一个条件语句,以输出特定产品用户的销售总额

更新代码:


非常感谢,它不起作用。轻微的设计错误,仅销售总额转移到下表而非下表。非常感谢。
<h1 class="page-header">Product Sales Report</h1></center>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <center>
 <form action="total_sales.php" method="post">
  From: <input type="text" class="datepicker" placeholder="E.G.(2018-01-14)" name="dayfrom" required pattern="[0-9]{4}+[0-9]+[0-9]"> To: <input type="text" class="datepicker" placeholder="E.G.(2018-02-11)" name="dayto" required pattern="[0-9]{4}+[0-9]+[0-9]">
  <input type="submit" value="Show Sales" name="salesbtn" ></form></center>

            <table width="100%" class="table table-striped table-bordered table-hover" id="prodTable">
                <thead>
                    <tr>
                        <th class="hidden"></th>
                        <th>Purchase Date</th>
                        <th>Customer</th>
                        <th>Product Name</th>
                        <th>Quantity</th>
                    </tr>
                </thead>
                <tbody>
                <?php
                    $sales_total_id = array();

                    $sq=mysqli_query($conn,"select * from sales_detail left join product on product.productid=sales_detail.productid left join sales on sales.salesid=sales_detail.salesid left join customer on sales.userid=customer.userid where product.supplierid='".$_SESSION['id']."' order by sales.sales_date desc");
                    while($sqrow=mysqli_fetch_array($sq)){
                        if( !isset( $sales_total_id[$sqrow['salesid']] ) ) {
                            $sales_total_id[$sqrow['salesid']] = TRUE;
                            ?>
                            <tr>
                            <td colspan="5" align="center"><strong>Sales Total: <?php echo $sqrow['sales_total']; ?></strong></td> 
                            </tr>
                            <?php
                        }
                    ?>
                        <tr>
                            <td class="hidden"></td>
                            <td><?php echo date('M d, Y h:i A',strtotime($sqrow['sales_date'])); ?></td>
                            <td><?php echo $sqrow['customer_name']; ?></td>
                            <td><?php echo $sqrow['product_name']; ?></td>
                            <td><?php echo $sqrow['sales_qty']; ?></td>
                        </tr>
                    <?php
                    }
                ?>
                </tbody>
            </table>
        </div>
    </div>