<?php include('up_index.php');?>
<?php include('loginok.php');?>
<script src="show.js"></script>

<center>
<form action="save_sale.php" method="post">
<br/>
<div class="table_product_show">


<p><br/>
ชำระค่าสินค้า</p>
<table width="1100"  border="1" cellpadding="0" cellspacing="0" id="product_show"  >	
  <tr>
		<td height="36" align="center" valign="middle">รายชื่อสินค้า</td>
		<td width="183" align="center" valign="middle">ราคาต่อชิ้น</td>
		<td width="183" align="center" valign="middle">จำนวน</td>
		<td width="183" align="center" valign="middle">ราคารวม</td>
    </tr>

	<?php
		$shopping=$_SESSION['shopping'];
		$shopping_array = explode(",", $shopping);//แยกเครื่องหมาย
		$shopping_num=sizeof($shopping_array);//จำนวน เริ่ม 1
		$number_shopping=$_SESSION['number_shopping'];
		$number_shopping_array = explode(",", $number_shopping);//แยกเครื่องหมาย
		if($_SESSION['shopping']!=""){
			for($shop_num=0;$shopping_num>$shop_num;$shop_num++){
				$strSQL = "SELECT * FROM product where id_product='".$shopping_array[$shop_num]."'";
				$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
				while($product = mysql_fetch_array($objQuery))
				{
		?>

		<tr>
		  <td align="left" valign="top"><?php echo substr($product['name_product'],0,100)." ";?></td>
			<td align="center" valign="top"><?=$product['price'];?></td>
		  <td align="center" valign="top"><label for="number_shopping[]"></label>
          <?=$number_shopping_array[$shop_num];?> <?php  $number_shop=$number_shop+$number_shopping_array[$shop_num];?></td>
			<td align="center" valign="top"><?php echo $product['price']*$number_shopping_array[$shop_num]; $number_shop_num=($number_shop_num+($product['price']*$number_shopping_array[$shop_num]));?></td>
			
		</tr>
	
	         
	<?php		} 
			}
		}
		?> 	
        <tr>
		  <td height="36" colspan="2" align="center" valign="middle">รวม</td>
		  <td width="183" align="center" valign="middle"><?=$number_shop;?></td> 
		  <td align="center" valign="middle"><?=$number_shop_num;?></td>
	  </tr>    
</table>

<br/>
	<input name="user_sale" type="hidden" value="<?=$chkuser;?>" />
	<input name="number_shopping_sale" type="hidden" value="<?=$_SESSION['number_shopping'];?>" />
	<input name="id_shopping_sale" type="hidden" value="<?=$_SESSION['shopping'];?>" />
  <input type="submit" name="update" id="update" value="ตกลง" />
  <input type="submit" name="dalete" id="dalete" value="ยกเลิกทำรายการ" />

<br/><br/>
</div>
</form>
<br/>

</center>
<?php include('down_index.php'); ?>