Creating Meaninful Customer ID
Posted: Tue Apr 25, 2006 1:20 pm
Hello All,
I am trying to populate automatically generated unique IDs into the Customer ID column in my table. However, I would like to append the two digit value of current month and year to a unique, ascending number up to 9999.
Example: This month's potential range would be 04060000 to 04069999.
I will set the field value to be unique on the table-side. Will this statement automatically generate the next available ID or create an error? Additionally, how can I have the $unique_id_int reset to 0 at month's change?
I am faily new to PHP (but have done some studying and tutorials thus far) so forgive any mistakes I've made.
Thank you kindly,
Michael
Code: Select all
<? php
//Creating unique part of ID
$unique_id_int=0
//Getting two digit value of month
$month=date(m);
//Getting two digit value of year
$year=date(y);
//Creating 'customerid' by concatenating month.year.unique.id.int
$customerid='$month.$year.$unique_id_int';
while ($unique_id_int<=9999);
$unique_id_int++;
//Here is the missing piece for which I need assistance
?>Example: This month's potential range would be 04060000 to 04069999.
I will set the field value to be unique on the table-side. Will this statement automatically generate the next available ID or create an error? Additionally, how can I have the $unique_id_int reset to 0 at month's change?
I am faily new to PHP (but have done some studying and tutorials thus far) so forgive any mistakes I've made.
Thank you kindly,
Michael