如何在php和sql中制作账单

时间:2016-05-24 18:17:43

标签: php mysql

我有网上商店,我在为每个订单制作账单时遇到问题

假设有人购买了2件T恤和1件鞋子,它将添加到有产品的台车桌上,usreid,数量,现在如果用户确认订单我怎么能用他买的所有商品创建账单并保存到名为bill的新数据库

请注意,同一用户可能会使用不同的商品

进行不同的帐单

这是显示订单和总价格的代码

function CallMyOrder($identificador)
{
	
	global $database_connectoos, $connectoos;
mysql_select_db($database_connectoos, $connectoos);
$query_CoryFuncion = sprintf("SELECT * FROM tbltrolley WHERE idUser = %s AND tbltrolley.intOrderDone = 1 , $identificador);
$CoryFuncion = mysql_query($query_CoryFuncion, $connectoos) or die(mysql_error());
$row_CoryFuncion = mysql_fetch_assoc($CoryFuncion);
$totalRows_CoryFuncion = mysql_num_rows($CoryFuncion);
?>
<?php
 if ($totalRows_CoryFuncion > 0) { // Show if recordset not empty 
echo " <li>  User : &nbsp;".CallUserName($row_CoryFuncion['idUser']);
$totalPrice =0;
 $pricemultnumber;

do {
	$pricemultnumber = $row_CoryFuncion['intQuantity'] * CallProductPrice($row_CoryFuncion['idProduct']);
	
echo "<li><br>";
echo "<img src='../document/product/".CallProductImage($row_CoryFuncion['idProduct'])."' border='0'/>";  	 
echo "Product Name : &nbsp;".CallProductName($row_CoryFuncion['idProduct']);
echo "<br>";
echo "Quantity : &nbsp;".$row_CoryFuncion['intQuantity'];
echo "<br>";
echo "Price : ".$pricemultnumber." RM";
echo "<br></li>";

$totalPrice = $totalPrice + $pricemultnumber;


} while ($row_CoryFuncion = mysql_fetch_assoc($CoryFuncion));
echo "<br>";
echo "<p style='font-size: 24px; font-weight: bold;'>Tax : ".CallTax()."</p>";

              $multp = (100 + CallTax())/100;
			  $totalPrice = $totalPrice * $multp;
	
echo "<p style='font-size: 24px; font-weight: bold;'>Total Price = ".$totalPrice." RM</p>";

 
}

0 个答案:

没有答案