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 10096 Atli 5,058
Recognized Expert Expert
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.
code green 1,726
Recognized Expert Top Contributor
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
Recognized Expert Expert
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 I do this ? I am not very capable in using
|
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 check.
Let's go straight to the point:
<script language="JavaScript">
alert("Date: "+Date.parse("2000-01-01"))
|
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 everything after and including the
final / removed to end up with simply 8/3
|
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 loop thru each record in Table1, split the long activity
durations according to their Working Hours shown in the Calendar field
and write these records to Table2.
|
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?
Thanks,
Doug
| |
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 inclination is to do roughly the same thing
that I would do in managed code: I would maintain a 64-bit integer value
that represents the number of millisec. (or nanosec.) since some date. I
would periodically increment this integer by the...
|
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 number of
|
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
incorporate into a database or CSV file. I want to search the email
for specific text.
The emails basically look like this:
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |