RE: Re: automatic call reference creation

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

 



Here's what you can do:

1. CREATE your table with an autoincrement column as well as a date
column.

2. When the customer service rep logs the call, they click on the submit
button, which will place the data into the DB

3. Right after you do the insert, (in PHP) do:
	$suffix = mysql_insert_id($Resource_id);

4. $padded_suffix = str_pad($suffix, 5, "0", STR_PAD_LEFT); // This will

// pad the $suffix with 0's (up to five characters)

5. $dat = dat("Y-m-d");

6. $callcode = $dat . $padded_suffix;

7. // Show them the call code
	echo "Your call code is $callcode";

You don't need to store the call code, since you can recreate it using
the autoincrement, the date field, and str_pad. Of course, if space is
not an issue, you could always store the concatenated string into
another column.



Gary Every
Sr. UNIX Administrator
Ingram Entertainment Inc.
2 Ingram Blvd, La Vergne, TN 37089
"Pay It Forward!"

-----Original Message-----
From: pete M [mailto:pmorgan@xxxxxxxx] 
Sent: Thursday, June 10, 2004 5:59 AM
To: php-db@xxxxxxxxxxxxx
Subject:  Re: automatic call reference creation

using the autoincrement you'd have to create the entry first !

otherwise your gonna have problems with concurrent users

Gawie Marais wrote:

> thanx for the replys guys... basically i need a PHP formula to
generate a
> 'call refenrence code' that is unique to give out to clients whenever
they
> log a call. this unique 'call reference code should be inserted into a
mysql
> field within a table.
> 
> all i need is a formula to get the last entered code and increment it
by
> one - the intended code should be forumated by php by using the
current date
> i.e. 20040101 + a numerical value i.e. 001 for the first 'call
reference
> code' for the day. when the next call is logged, the next unique
available
> numerical should be assigned and combined with the date to form the
call
> reference number.
> 
> hope this makes it a bit clearer.
> 
> 
> 
> 
> "Pete M" <pmorgan@xxxxxxxx> wrote in message
> news:20040610102921.4526.qmail@xxxxxxxxxxxxxxx
> 
>>not sure what u want here but
>>have you looked at the identiry field ??
>>its called auto_increment in mysql and this gives it record in a
>>database a unique number
>>
>>eg
>>"Insert into table (date_call)values(now() )"
>>
>>then after the insert do
>>"select last_insert_id()"
>>
>>pedro
>>
>>Gawie Marais wrote:
>>
>>>hi all,
>>>
>>>i need to create an automatic call reference. i though it would work
> 
> using
> 
>>>the date as ccyymmdd and by adding a '001', '002', etc to the end.
>>>
>>>now, i know how to format the date but how would i increment the 001,
> 
> 002 at
> 
>>>the end... ? i understand that i would have to check back to the
> 
> database to
> 
>>>check the last one used. but how... ?
>>>
>>>alternatively is to just generate a random number, check it against
the
>>>database to see if it's not already used. if not use it. if its used
>>>already, just create another one... ?
>>>
>>>OR
>>>
>>>do you guys have any laternative suggestions ?
>>>
>>>
>>>Regards,
>>>
>>>Gawie.

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

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



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux