Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Best way to generate transaction id for a point of sale appl

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Best way to generate transaction id for a point of sale appl

Postby mukeshprasad4u » Tue Feb 19, 2013 6:24 pm

Hi ,
I am new to the php.I am building an php pos application to learn php by doing.
I want to generate a unique transaction id whenever any transactions like purchase order,purchase return,sales or sales return etc.
But confused how to accomplise this.Is uniquid feature of php is sufficeint for this.
I wanted to generate it in format like PO20130220001 ie. PO+date+3 or 4 digit number.

Any kind of suggestion is of great help to me.
mukeshprasad4u
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue Feb 19, 2013 6:16 pm

Re: Best way to generate transaction id for a point of sale

Postby simplypixie » Tue Feb 19, 2013 10:27 pm

Code: Select all
$date = date('Ymd');
$numbers = '0123456789';
for ($i=0; $i<$4; $i++) {
      $rand_num.=$numbers{rand(0,strlen($numbers)-1)};
   }
$transaction_id = 'PO'.$date.''.$rand_number;
User avatar
simplypixie
php-forum Active User
php-forum Active User
 
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire


Return to PHP coding => General

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.