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---
6 10078 Atli 5,058
Expert 4TB
Hi momogi.
You could simply do this:
$refku would technically be a string, but PHP is smart enough to convert it into whatever type it needs to be in various situations.
For example: -
$refku = date("Ymd", time()) . "01";
-
# Now $refku is a string "2007092401"
-
-
echo "refku plus one: ". ($refku + 1);
-
# Will output "refku plus one: 2007092402"
-
Hi momogi.
You could simply do this:
$refku would technically be a string, but PHP is smart enough to convert it into whatever type it needs to be in various situations.
For example: -
$refku = date("Ymd", time()) . "01";
-
# Now $refku is a string "2007092401"
-
-
echo "refku plus one: ". ($refku + 1);
-
# Will output "refku plus one: 2007092402"
-
Hi Atli...
thx 4 your reply... :)
But I have to say that it doesn't work.
My text field still empty,,, (except I enter the today's reference manually in database).
Is there another solution? thx b4.
But I have to say that it doesn't work.Is there another solution?
Atli's solution will work.
You have obviously asked the wrong question which was
Parse the date into integer
My text field still empty,,,
Is this you problem? If so, what text field and where?
Atli's solution will work.
You have obviously asked the wrong question which was Is this you problem? If so, what text field and where?
Hi...
The text field is a field where I wanna put my reference number automatically. its placed in the top of my form.
if the user haven't fill the form at the day, the form will generate the reference number automatically which started with the date.
hope that was clear 4 you. I'm sorry if I was ask the wrong question...
gbu.
Atli 5,058
Expert 4TB
Try something like this: -
# Execute query and get row
-
$ref = date("Ymd", time());
-
$query = "SELECT MAX(noreff) AS 'A' FROM tblref WHERE noreff LIKE '$ref%' ";
-
$result=mysql_query($query) or die("Query failed");
-
$row=mysql_fetch_assoc($result);
-
-
# Create reference
-
if(@isset($row['A'])) {
-
$refku = $row['A'];
-
}
-
else {
-
$refku = $ref . "01";
-
}
-
-
# Print reference
-
echo "<input name=\"noreff\" type=\"text\" value=\"$refku\" maxlength=10 /></td> "
-
Try something like this: -
# Execute query and get row
-
$ref = date("Ymd", time());
-
$query = "SELECT MAX(noreff) AS 'A' FROM tblref WHERE noreff LIKE '$ref%' ";
-
$result=mysql_query($query) or die("Query failed");
-
$row=mysql_fetch_assoc($result);
-
-
# Create reference
-
if(@isset($row['A'])) {
-
$refku = $row['A'];
-
}
-
else {
-
$refku = $ref . "01";
-
}
-
-
# Print reference
-
echo ("<input name=\"noreff\" type=\"text\" value=\"$refku\" maxlength=10 /></td> "
-
}
-
whoaaa... it works!!!
thanks...
thanks... :)
and thanks... :D
Sign in to post your reply or Sign up for a free account.
Similar topics
by: serpent17 |
last post by:
Hello all,
I have this line of numbers:
04242005 18:20:42-0.000002, 271.1748608, , ,
repeated several times in a text file and I would like each element to
be part of a vector. how do...
|
by: Matteo |
last post by:
Hy everybody.
I'm not a html writer, but a sysadmin who's trying to help a user able
to compile an online form with IE but not with Mozilla (Moz1.6, Ns7.1,
Firefox 0.8+) due to a javascript date...
|
by: Ken Bush |
last post by:
How can I write an update query that removes part of a field? Like if I
have a field with values such as 8/3/68 (a birthday obviously) and I need
to put values in a new column but I need...
|
by: u473 |
last post by:
I am still a beginner with VBA and I need the VBA Code for the
following problem.
I have a list of activities with their Scheduled Start date, Duration,
and Working hours in Table1.
I need to...
|
by: Doug Bell |
last post by:
Hi,
I have some data in the format of yyyymmdd (Int32) that I want to display,
in a datagrid, formatted in International Date Format dd MM yyyy.
Any suggestions on an efficient approach?
...
|
by: Bob Altman |
last post by:
Hi all,
I need to simulate current date and time and provide integer values for the
current year, month, day, hour, minute, second, and millisec. I need to do
this in unmanaged C++. My first...
|
by: gs |
last post by:
let say I have to deal with various date format and I am give format string
from one of the following
dd/mm/yyyy
mm/dd/yyyy
dd/mmm/yyyy
mmm/dd/yyyy
dd/mm/yy
mm/dd/yy
dd/mmm/yy
mmm/dd/yy
|
by: Ben |
last post by:
Hi,
Can anyone explain why this,
Date.parse("Jan 1, 1970")
equals this,
18000000
?
Microsoft's documentation reports this, "
The parse method returns an integer value representing the...
|
by: dpw.asdf |
last post by:
I have been searching all over for a solution to this. I am new to
Python, so I'm a little lost. Any pointers would be a great help. I
have a couple hundred emails that contain data I would like to...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |