<?php
session_start() ;

if(session_is_registered("login_true_admin")) {
      //$usern = $_SESSION["login_true_admin"];
      $usern = "Administator";
	  $mlevel=3 ;
}elseif(session_is_registered("login_true")){
      $usern = $_SESSION["login_true"];
      $mlevel = $_SESSION["member_level"];	  
}else{
      $usern = "offline";
	  $mlevel=-1; 
      echo "<script>window.close();</script>" ;  
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="th" lang="th" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>สินค้า</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #000000;
}
body,td,th {
	color: #FFFFFF;
}
-->
</style></head>

<body>
<form action="cart.php?show=30" method="get" target="_blank">
             <img src="zz0504.php?id=<?php echo $id ?>" />

<?php 


include("./member/config.inc.php") ;
mysql_select_db($db) ;
@mysql_select_db($db) or die( "Unable to select database");
mysql_db_query($db,"SET NAMES tis620");// 

$query="SELECT * FROM product WHERE id = $id ";

mysql_query("SET character_set_results=tis620");
mysql_query("SET character_set_client=''tis620''");
mysql_query("SET character_set_connection=''tis620''");
mysql_query("collation_connection = tis620_thai_ci");
mysql_query("collation_database = tis620_thai_ci");
mysql_query("collation_server = tis620_thai_ci");

$result=mysql_query($query);
$num=mysql_numrows($result);

if($num>0)
{

$type =mysql_result($result,$i,"type");
$groups=mysql_result($result,$i,"groups");
$model=mysql_result($result,$i,"model");
$name=mysql_result($result,$i,"name");
$weight=mysql_result($result,$i,"weight");
$amount=mysql_result($result,$i,"amount");
$level=mysql_result($result,$i,"level");
$timerec=mysql_result($result,$i,"timerec");
echo "  <table cellspacing=0 width=100% >
             <tr><td valign=top width=50%><strong>
               <font size=2 color=\"ffffff\" >
               รหัสสินค้า : <font size=2 color=\"ffffaa\">$model </font> <br>
			   ชื่อลาย :  <font size=2 color=\"ffffaa\">$name </font><br>
			   ประเภท :  <font size=2 color=\"ffffaa\">$type </font><br>
			   กลุ่ม : <font size=2 color=\"ffffaa\">$groups </font><br>
			   น้ำหนัก : <font size=2 color=\"ffffaa\">$weight  </font>
			   </font></strong>
			   </td><td  valign=top  width=50%><strong>
               <font size=2 color=\"ffffff\">
			   ห้างขายทอง ทองใบเยาวราช <br>
			   โทร.<font size=2 color=\"ffffaa\">0-2226-1235</font> <br>
			   โทรสาร.<font size=2 color=\"ffffaa\">0-2226-3742 </font>		   
			   </font></strong> ";
echo "<a href=\"javascript:window.print();\"><img src=\"images/printer.JPG\"  vspace=\"2\" border=\"0\" /></a> ";
                        		 }
echo "</td></table>";
		 if($mlevel==2) {
mysql_query("SET character_set_results=tis620");
mysql_query("SET character_set_client=''tis620''");
mysql_query("SET character_set_connection=''tis620''");
mysql_query("collation_connection = tis620_thai_ci");
mysql_query("collation_database = tis620_thai_ci");
mysql_query("collation_server = tis620_thai_ci");
$query="SELECT * FROM productsize WHERE name = '$type' ";
$result=mysql_query($query);
$num=mysql_numrows($result);
//echo "---$num---";
echo  "<select name=\"idsize\" id=\"idsize\">";
for($i=0;$i<$num;$i++)
{
  $idsize =mysql_result($result,$i,"id");
  $name =mysql_result($result,$i,"name");
  $weight =mysql_result($result,$i,"weight");
  $size =mysql_result($result,$i,"size");
  $unit =mysql_result($result,$i,"unit");
  $unit2 =mysql_result($result,$i,"unit2");
  
  if($i==0)
  {    
      echo "<option value=\"$idsize\" selected=\"selected\">น้ำหนัก $weight</option>";
  }else{
               echo "<option value=\"$idsize\">น้ำหนัก $weight</option>";
           }
}
echo "</select><select name=\"idsize2\" id=\"idsize2\">";
$query="SELECT * FROM productsize2   WHERE name = '$type'  ";
$result=mysql_query($query);
$num=mysql_numrows($result);
for($i=0;$i<$num;$i++)
{
  $idsize =mysql_result($result,$i,"id");
  $name =mysql_result($result,$i,"name");
  $weight =mysql_result($result,$i,"weight");
  $size =mysql_result($result,$i,"size");
  $unit =mysql_result($result,$i,"unit");
  $unit2 =mysql_result($result,$i,"unit2");
   echo "<option value=\"$idsize\">ขนาด $size $unit2</option>";
}

echo " </select><input name=\"add2cart\" type=\"hidden\" id=\"add2cart\" value=\"$id\" />จำนวน<input name=\"amount\" type=\"text\" id=\"amount\" value=\"1\" size=\"3\"><input type=\"submit\" name=\"Submit\" value=\"สั่ง\" onclick='window.close();' />";
mysql_close();
}
?>

</body>
</html>
