Hello,
We need a piece of PHP code to generate random 3-digit numbers as part of the order numbers in our CRE Loaded site.
This should be an easy job. We need somebody code it quickly.
Requirements:
1. The generated random number has to be 3-digit (000-999)
2. There can not be duplicate numbers in the same day period
3. We will create the SQL table on your request
For your reference. Here is the flowchart showing our idea. You don't have to exactly follow it if you have a better idea.
Start
|
Check the date of the
numbers in table
|
| n clear table and
Same day? ------> reset the date
| |
| y |
$abc = rand (0, 999) <---|
| |
| |
Duplicate number y |
found in table? ------>
|
| n
Insert $abc
into table
|
| n
$abc < 100 ? ---------
| |
| y |
Add prefix 0 or 00 |
to make $abc 3-digit |
| <-------------
$ordernum=date("ymd").$abc
|
End
Hello,
work can be done. If you wish, we are able to make a script working for you on our servers, and you will bee able to see fully working script.
Also we are able to provide you script using .txt database.
Regards