如何在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;
}
?>发布于 2018-05-14 11:33:28
用每一行的总数循环遍历所有表格单元格如何?首先,给单元格一个我们可以参考的类(例如,汇总框)。
在jQuery中:
var total = 0;
$('.totalbox').each(function(){
boxTotal = $(this).html();
total = total + boxTotal;
});
$('#some-other-div').html(total);您可能需要将val解析为一个数字,它很可能被视为一个字符串。
https://stackoverflow.com/questions/50327533
复制相似问题