我应该编辑什么,以便我的合计将添加所有可能的变量($order_stotal)


What should I edit so that my total will add all the possible variable ($order_stotal)

这个怎么样?这是我的最高准则,但我认为这是无助的。每次三阶运算都是错误的。

<?php
include("dbconnection.php");
if ($_SESSION["loggedin"] != "true") 
header("Location:memberlogin.php");
$cust_id = $_SESSION["cust_id"];

从数据库中选择全部

$result = mysql_query("select customer.*, product.*, order_details.* from customer, product,  order_details where customer.cust_id=$cust_id and product.pro_id=product.pro_id and order_details.order_details_id = order_details.order_details_id")or die(mysql_error());
$row = mysql_fetch_assoc($result);  
?>
    <?php
        $x=1;
        $bill_total=5.00;
        $order_stotal=$row["order_stotal"];
        $result = mysql_query("select product.*,order_details.* from product,order_details 
        where order_details.pro_id= product.pro_id ");
        while($row=mysql_fetch_assoc($result))
        {
        ?>

我需要它来回应所有可能的小计。我想我只需要编辑这个或其他什么我不太确定

        <?php 
        $x++;
        $bill_total +=$order_stotal;
        } 
        ?>
                RM &nbsp
                <?php
                echo number_format($bill_total,2);
                ?>

这个是按钮的功能

<?php

if(isset($_POST["submitbtn"]))
{
$bill_id=rand(1000,9999);
$bill_date=date("Y-m-d"); 
$bill_state=$_POST["bill_state"];
$bill_city=$_POST["bill_city"];
$bill_add=$_POST["bill_add"];
$bill_post=$_POST["bill_post"];
mysql_query("insert into bill
(cust_id, bill_date, bill_total, bill_state, bill_city, bill_add, 
bill_post)
 values('$cust_id','$bill_date', 
'$bill_total', '$bill_state', '$bill_city','$bill_add','$bill_post')")or die(mysql_error());
}
?>
$bill_total +=$row['order_stotal'];

这应该适用于组合数据库检索的行中该行的所有值。

(您还需要在查询之前删除对$row['order_stotal']的引用,除非您使用的是与脚本另一部分不同的查询来设置它。)