Assigning a file number

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

John



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux