<?php include('up_index.php');?>

<script src="show.js"></script>

<center>
<form action="shopping.php" method="post">
<br/>
<div class="table_product_show">
<a href="product_show.php"><div class="link1">เลือกสินค้าต่อ</div></a><a href="sale_link.php"><div class="link2">ชำระค่าสินค้า</div></a>

<br/>
<table width="1200"  border="0" cellpadding="0" cellspacing="0" id="product_show"  >	
	<tr>
		<td width="189" height="36" align="center" valign="middle" bgcolor="#66CCFF">รูปภาพ</td>
		<td width="393" align="center" valign="middle" bgcolor="#66CCFF">ชื่อสินค้า</td>
		<td width="183" align="center" valign="middle" bgcolor="#66CCFF">ราคาต่อชิ้น</td>
		<td width="183" align="center" valign="middle" bgcolor="#66CCFF">จำนวน</td>
		<td width="183" align="center" valign="middle" bgcolor="#66CCFF">ราคารวม</td>
    </tr>
    <tr>
		  <td colspan="5" align="center" valign="middle" bgcolor="#009999"><hr /></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="center" valign="middle" bgcolor="#009999"><img class="img" src="upload/<?=$product['image1'];?>" width="200" height="200" /></td>
			<td align="left" valign="top" bgcolor="#009999">
				
					
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
					  <tr>
					    <td height="180" align="left" valign="top"><a href="product_show_full.php?id_product=<?=$product['id_product'];?>" title="<?php echo $product['name_product'];?>"><?php echo substr($product['name_product'],0,100)." ";?></a></td>
				      </tr>
					  <tr>
					    <td><a href="shopping.php?id_product=<?=$product['id_product']?>" ><img src="images/delete.png" width="20" height="20" />ลบรายการสินค้า</a></td>
				      </tr>
			  </table></td>
			<td align="center" valign="top" bgcolor="#3399CC"><?=$product['price'];?></td>
		  <td align="center" valign="top" bgcolor="#3399CC"><label for="number_shopping[]"></label>
	      <input name="number_shopping[]" type="text" id="number_shopping[]" value="<?=$number_shopping_array[$shop_num];?>" size="2" maxlength="3" />		    <?php  $number_shop=$number_shop+$number_shopping_array[$shop_num];?></td>
			<td align="center" valign="top" bgcolor="#3399CC"><?php echo $product['price']*$number_shopping_array[$shop_num]; $number_shop_num=($number_shop_num+($product['price']*$number_shopping_array[$shop_num]));?></td>
			
		</tr>
		<tr>
		  <td colspan="5" align="center" valign="middle" bgcolor="#009999"><hr /></td>
	  </tr>
	         
	<?php		} 
			}
		}
		?> 	
        <tr>
		  <td height="36" colspan="3" align="center" valign="middle" bgcolor="#FF6600">รวม</td>
		  <td width="50" align="center" valign="middle" bgcolor="#FF0000"><?=$number_shop;?></td> 
		  <td align="center" valign="middle" bgcolor="#FF0000"><?=$number_shop_num;?></td>
	  </tr>    
</table>

<br/>

  <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'); ?>