I' making an database application. In one form (Input data Form), I need to fill the text field with the reference number automatically. This number must be start with date of today. For the example,
2007092401. And the text field must be filled with the largest number in database (the largest of that day).
Firstly, the form will check if there's a number start with today's date. If it's not NULL, the form takes the biggest one. But if it returns NULL, I wanna make a number that start with today's date. But I don't know how to join the date (I take the date with time's function) and the '01'...
(PS : the type of my reference number's field in MySQL is integer)
Here's a piece of my code.
-
$now=time();
-
$ref=date("Ymd",$now);
-
-
$refku=implode($ref,"01"); // I need some help here
-
-
$peri="select max(noreff) as A from tblref where noreff like '$ref%' ";
-
$hasil=mysql_query($peri);
-
$row=mysql_fetch_array($hasil);
-
-
if($row!=NULL)
-
{
-
echo (" <input name=\"noreff\" type=\"text\" value=\"$row[A]\" maxlength=10></td> ");
-
}
-
-
else
-
{
-
echo (" <input name=\"noreff\" type=\"text\" value=\"$refku\" maxlength=10 /></td> ");
-
}
-
---Thank You---