<?
include ("connect.php");
//*** Connect to Database **//
$link = mysql_connect($host,$user,$pass) or die ("Connect Mysql Error");
mysql_select_db ($dbname,$link) ;
$cid = "";
//*** Check Year ***//
$sql = "SELECT * FROM customers WHERE 1 ";
$result = mysql_query ($sql) or die ("Error Query [".$strSQL."]");
$row = mysql_fetch_array($result);
//*** Check val = year now ***//
if($row["val"] == date("M"))
{
$Seq = substr("00".$row["seq"],-2,2); //*** Replace Zero Fill ***//
$cid = $row["val"]."-".$Seq;
//*** Update Next Seq ***//
$strSQL = "UPDATE customers SET seq= seq+1 ";
$result = mysql_query($sql) or die ("Error Query [".$strSQL."]");
}
else //*** Check val != year now ***//
{
$Seq = substr("01",-2,2); //*** Replace Zero Fill ***//
$cid = date("M")."-".$Seq;
//*** Update New Seq ***//
$strSQL = "UPDATE customers SET val = '".date("M")."' , seq = '1' ";
$result = mysql_query($sql) or die ("Error Query [".$strSQL."]");
}
echo $cid;
?>