John Taylor-Johnston wrote:
I need to assign a unique file number
50-20131103-0001
Ussers work in secteur 50
Today is 20131101
The first file number possible today is 0001 (of probably no more than
9999.
How should I build this?
Should I
create a varchar in MySQL and stock it all in one field?
or
have three separate fields?
secteur: '50' (INT) default=50
date: (DATESTAMP)
filenumber 0001 (INT)
Then here comes the PHP question?
When a user opens up my php page, my code will automatically assign
$filenumber sequentially.
So how do I check if $filenumber = 0001 exists already? Using a while
or if seems like a lot of work. Swatting a fly with a baseball bat.
There must be an easier trick, maybe a MySQL function to says if 0001
is taken, check and see if 0002 is available ++ until one is free.
Then INSERT it so my user can enter his data.
Failing that I could use an INT field that auto_increments everytime I
INSERT. But a I will want to express a value of 33 as 0033, or 2 as 0002
- in four digits. How can I do that?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php