Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.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
Javascript 在与ajax输出表分开的ajax调用页面中显示从ajax操作页面到的总金额_Javascript_Php_Ajax - Fatal编程技术网

Javascript 在与ajax输出表分开的ajax调用页面中显示从ajax操作页面到的总金额

Javascript 在与ajax输出表分开的ajax调用页面中显示从ajax操作页面到的总金额,javascript,php,ajax,Javascript,Php,Ajax,如何在下面的ajax退货输出表中显示sales表中的总金额,然后在调用页面中如何传递和接受 ajax操作页面 $customer=$_POST["from_date"]; $item=$_POST["to_date"]; $quantity=$_POST["qty"]; $ins=mysqli_query($connect,"INSERT INTO sale(pr_id,customer_name,item,quantity,sale_date) VALUES ('$item','$

如何在下面的ajax退货输出表中显示sales表中的总金额,然后在调用页面中如何传递和接受

ajax操作页面

$customer=$_POST["from_date"];
  $item=$_POST["to_date"];
  $quantity=$_POST["qty"];
  $ins=mysqli_query($connect,"INSERT INTO sale(pr_id,customer_name,item,quantity,sale_date) VALUES ('$item','$customer','$item','$quantity','$date')");
  $query="SELECT p.pr_name,  p.mrp, s.quantity,s.customer_name FROM sale s JOIN product p ON ( s.pr_id = p.pr_id ) WHERE s.customer_name = '$customer' AND p.pr_id = '$item'";
  $result = mysqli_query($connect, $query);  
  $output = '';  
if(mysqli_num_rows($result) > 0)  
{  $i=0;
  while($row = mysqli_fetch_array($result))  
       { 
            $output .= '  
                 <tr> 
                      <td>'.$i.'</td> 
                      <td>'. $row["pr_name"] .'</td> 
                      <td>'. $row["quantity"] .'</td> 
                      <td>'. $row["mrp"] .'</td>  
                 </tr>  
            ';  
              $output .= '  

            ';  
$i++;
       }  
  }  
  else  
  {  
       $output .= '  
            <tr>  
                 <td colspan="5">No Order Found</td>  
            </tr>  
       ';  
  }  

  $output .= ' <tr> 
  <td><?php echo $i++; ?></td>
  <td>'. $row["pr_name"] .'</td> 
  <td>'. $row["quantity"] .'</td>
  <td>'. $row["mrp"] .'</td> 
  </tr>    
  ';  
  echo $output;  
}  
?>
$customer=$\u POST[“from\u date”];
$item=$\u POST[“截止日期”];
$quantity=$_POST[“数量”];
$ins=mysqli_query($connect,“插入销售(pr_id、客户名称、项目、数量、销售日期)值(“$item”、“$customer”、“$item”、“$quantity”、“$date”)));
$query=“从销售中选择p.pr\U名称、p.mrp、s.QUOTE、s.customer\U名称加入产品p ON(s.pr\U id=p.pr\U id),其中s.customer\U名称=‘$customer’和p.pr\U id=‘$item’;
$result=mysqli\u查询($connect,$query);
$output='';
如果(mysqli_num_行($result)>0)
{$i=0;
while($row=mysqli\u fetch\u数组($result))
{ 
$output.='
“.$i.”
“.$row[“pr_name”]”
“.$row[“数量”]”
“.$row[“mrp”]”
';  
$output.='
';  
$i++;
}  
}  
其他的
{  
$output.='
找不到订单
';  
}  
$output.='
“.$row[“pr_name”]”
“.$row[“数量”]”
“.$row[“mrp”]”
';  
echo$输出;
}  
?>

将每行的总数循环到所有表格单元格如何?首先,给单元格一个我们可以参考的类(例如totalbox)

在jQuery中:

var total = 0;
$('.totalbox').each(function(){
    boxTotal = $(this).html();    
    total = total + boxTotal;
});
$('#some-other-div').html(total);

您可能需要将val解析为一个数字,它很可能被视为一个字符串。

您的意思是
$.get(“actionpage.php”,{“from_date”:fromdate,“to_date”:todate,“qty”:quantity},函数(data){$(“table>tbody”).append(data)})“我想要”不能解释问题。你在实现目标方面遇到了什么问题?问题是什么?花几分钟阅读@charlietfl-英语显然不是OPs第一语言事实上我已经使用query获取了total,现在我想把它传递到ajax调用页面中。在上面的代码中显示一个表,现在我想在该表下面显示total