<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>ห้างขายทอง ทองใบเยาวราช</title>
<?
function DateThai($strDate)
	{
		$strYear = date("Y",strtotime($strDate))+543;
		$strMonth = date("n",strtotime($strDate));
		$strDay = date("j",strtotime($strDate));
		$strHour = date("H",strtotime($strDate));
		$strMinute = date("i",strtotime($strDate));
		$strSeconds = date("s",strtotime($strDate));
		$strMonthCut = Array("","มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤษจิกายน","ธันวาคม");
		$strMonthThai=$strMonthCut[$strMonth];
		return "$strDay $strMonthThai $strYear";
//		return "$strDay $strMonthThai $strYear, $strHour:$strMinute";
	}
	

$nd=date("w ") ;
switch ($nd)
{
case 0 :
$bgc="#ed1c24";
$nday="อาทิตย์";
$fc="c00000";
break;  
case 1:
$bgc="#ffff00";
$nday="จันทร์";
$fc="#FF9900";
break;
case 2:
$bgc="#ed145b";
$nday="อังคาร";
$fc="f20be4";
break;
case 3:
$bgc="#197b30";
$nday="พุธ";
$fc="#008800";
break;
case 4:
$bgc="#f26522";
$nday="พฤหัสบดี";
$fc="#FF6600";
break;
case 5:
$bgc="#0054a6";
$nday="ศุกร์";
$fc="#000088";
break;
case 6:
$bgc="#9f929f";
$nday="เสาร์";
$fc="#92278f";
break;
default:
$bgc="#FFFFFF";
$fc="#000000";

}
	
?>

<style type="text/css">
<!--
body {
	background-image: url(ng.PNG);
	background-repeat: no-repeat;
	background-position: center top;
	background-color: <? echo $bgc ?>;
}
.style1 {color: #FF0000}
.style14 {font-size: 14px}
.style31 {	font-size: 42px;
	color: #FF0000;
}
.style32 {
	font-size: 36px;
	color: #003399;
	font-weight: bold;
	font-family: Tahoma, "Microsoft Sans Serif";
}
.style35 {
	font-size: 39px;
	color: #CC0000;
	font-weight: bold;
}
.style36 {
	font-size: 36px;
	color: #336600;
	font-weight: bold;
	font-family: Tahoma, "Microsoft Sans Serif";
}
-->
</style>
<meta http-equiv="Refresh" content="60;URL=" />
</head>

<body>
<table width="100%" border="0">
  <tr>
    <td height="162" align="center" valign="top"><table width="749" border="0">
      <tr>
        <td height="41">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td height="130">&nbsp;</td>
        <td align="left"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="600" height="114">
          <param name="movie" value="eff1.swf" />
          <param name="quality" value="high" />
          <param name="wmode" value="transparent" />
          <embed src="eff1.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="114"></embed>
        </object></td>
      </tr>
      <tr>
        <td width="26" align="right" valign="bottom">&nbsp;</td>
        <td width="713" align="center" valign="bottom"><? echo"<font color=#880055 size=6>$name</font>" ?>&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td  align="center" valign="top"><table width="700" border="0">
      <tr>
        <td align="center">
		<? if($hiddenField!=1){?>
		<form id="form1" name="form1" method="get" action="">
		  <strong>ข้อความ</strong>
		  <input name="name" type="text" id="name" />

          <input type="submit" name="Submit" value="Submit" />
          <input name="hiddenField" type="hidden" value="1" />

        </form>
		    <?php  }
$d=date("Y-m-d",strtotime("-1 week"));  		
$sd=date(" D, d/M/Y     H:i:s");


$user="cp037684_tbadm";
$password="siamnovaTho1220!";
$database="cp037684_tbadm";



mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");


														
$query="SELECT * FROM goldprice   ORDER BY date  DESC, time DESC LIMIT 2"; //
$result=mysql_query($query);

//$num=mysql_numrows($result);
$num=1;

mysql_close();

$i=0;

$date2 =$date;

$id=mysql_result($result,$i,"id");
$date=mysql_result($result,$i,"date");
$time=mysql_result($result,$i,"time");
$b96sb=mysql_result($result,$i,"b96sb");
$b96bb =mysql_result($result,$i,"b96bb");
$o96bg =mysql_result($result,$i,"o96bg");
$o96sb=mysql_result($result,$i,"o96sb");
$o96bb=mysql_result($result,$i,"o96bb");
$g90bg=$o96bg*.9;
$g90sb=$g90bg*15.16;
$g40bg=round($o96bg*.35);
$g40sb=$g40bg*15.16;

$dateshow=DateThai($date);
$dd=date("w",strtotime($date));

                  $p_old =mysql_result($result,($i+1),"b96bb");
				  $diff=$b96bb-$p_old ;
			      $err=0;


switch ($dd)
{
case 0;
$nday="อาทิตย์";
break;  
case 1:
$nday="จันทร์";
break;
case 2:
$nday="อังคาร";
break;
case 3:
$nday="พุธ";
break;
case 4:
$nday="พฤหัสบดี";
break;
case 5:
$nday="วันศุกร์";
break;
case 6:
$nday="เสาร์";
break;
default:
$bgc="images/bg_whi";
$fc="000000";

}


     $dbuf=date("d");
	 $d1=sprintf("%02d", $dbuf);
	 $d0=date("D");
	 $yb=date("y")+43;
	 $y1=sprintf("%02d", $yb);
	 $mb = date("m");
	 $m=sprintf("m%d", $mb);
	 
	 $d11=$d1[0]*10;
	 $d10=$d1[1];
	 
	  	 
	 $sBuf=round($b96bb ); 
	 $sB=sprintf("%05d", $sBuf);

	 $sBuf=round( $b96sb);
	 $bB=sprintf("%05d", $sBuf);
	 
	  if($y1[1] ==1) $y11="01";
	 

		  if($diff==0)
		         {
				       $arr="price_eq.swf";
				       $cp="#0000ff";
				 }
		  if($diff>0)
		         {
  		  				$arr="price_up.swf";
				       $cp="#00ff00";						
		          }
		  if($diff<0)
		         {
  		  				$arr="price_dw.swf";
				       $cp="#ff0000";
						
				}		
?><br><span class="style32">
	      ทองคำแท่ง 96.5%</span>
	      <table width="100%" border="0" cellspacing="2" cellpadding="0">
	        <tr>
	          <td align="left" class="style35">ขายบาทละ</td>
	          <td align="right"><strong><span class="style31"><?php echo number_format($b96sb) ?></span></strong></td>
	          <td align="right" class="style35"><strong>&nbsp;บาท</strong></td>
	          </tr>
              <tr>
                <td width="33%" align="left" class="style35"><strong>รับซื้อบาทละ</strong></td>
                <td width="40%" align="right" class="style31"><strong><?php echo number_format($b96bb) ?></strong></td>
                <td width="27%" align="right" class="style35"><strong>&nbsp;บาท</strong></td>
              </tr>
            </table>
          <br />
           </span><span class="style36">ทองคำแท่ง 99.99%</span><br />
            
            <table width="100%" border="0" cellspacing="2" cellpadding="0">
              <tr>
                <td align="left" class="style31"><strong class="style35">ขายบาทละ</strong></td>
                <td align="right" class="style31"><strong><?php echo number_format($o96bg) ?></strong></td>
                <td align="right" class="style31">&nbsp;<strong class="style35">บาท</strong></td>
              </tr>
              <tr>
                <td width="33%" align="left" class="style1 style14"><strong><span class="style35">รับซื้อบาทละ</span></strong></td>
                <td width="40%" align="right" class="style31"><strong><?php echo number_format($o96bb, 2, '.', ',') ?></strong></td>
                <td width="27%" align="right" class="style31">&nbsp;<strong class="style35">บาท</strong></td>
              </tr>
            </table>			
		     <strong>
		     </strong><br />
<strong>  
            <?php 
					                                                                        echo "<font color=$fc  size=5>&nbsp; วัน$nday ที่ $dateshow  <br> &nbsp; &nbsp; เวลา $time</font >" ; 
																												 ?>
             </strong>   </td>
      </tr>
    </table>
      <p>&nbsp;</p></td>
  </tr>
</table>
</body>
</html>
