Forum Moderators: coopster
so the finaly random invoice number might be
microsoft_5f55_22 i.e (companyName_fourRandomDigits_customerID)
This would make the most sense, and make sure that only unique id's are populated in the database.
Good luck :)
To start with an AUTO_INCREMENT value other than 1, you can set that value with CREATE TABLE or ALTER TABLE, like this:mysql> ALTER TABLE tbl AUTO_INCREMENT = 100;
[edit]
I just realized what you were asking...ooops...I'm not sure how to put leading zeros on an auto increment without manipulating it server-side after you select the results.
say you have unique id in $row[pid] that contains '1' then while generating invoice value use,
echo "Your Invoice Number is: 000{$row[pid]}";
but wait if you want to run this series as auto incremented every time a new invoice is generated then you can write an IF statement that will first check the number of digits in the $row[] value and then accordingly put 0s before the value e.g if it has two digits then put two 0s before the value.
you can write an IF statement that will first check the number of digits
$input = 24;
echo str_pad($input, 7, "0", STR_PAD_LEFT); // 0000024
companyName_customerID_date
e.g
Oracle_345_20070106
this helped a lot us in searching invoices and also invoice name gives full information that for whom it belongs to, customerID for a quick client search in DB and date immediately tells you the dispatched date of the invoices.
and these are the most commonly searched three attributes about an invoice and you get this info just by reading the invoice name.