I-AM-OBODO Posted July 19, 2008 Share Posted July 19, 2008 Helo. How do i insert letters on my unique id. I mean i designed a form that a user fills to make a request. I want each request a user makes it should have its own unique transaction ID. and since i have more than just one form that needs be filled (on other pages there's form for other transactions), i want to adentify each form with a unique number exaple EN001 for a particular form and SE001 for another form etc. I tried but dont know a way out of this. These my code: CREATE TABLE `transactions` ( `tranxID` int(255) NOT NULL auto_increment, `product_code` varchar(50) NOT NULL, `trans_type` varchar(50) NOT NULL, `pay_type` varchar(50) NOT NULL, `fname` varchar(50) NOT NULL, `lname` varchar(50) NOT NULL, `address` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, `date_of_order` date NOT NULL, PRIMARY KEY (`tranxID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; -- -- Dumping data for table `transactions` -- INSERT INTO `transactions` (`tranxID`, `product_code`, `trans_type`, `pay_type`, `fname`, `lname`, `address`, `email`, `date_of_order`) VALUES (1, '12345', 'single', 'cheque', 'chidi', 'obodo', '31 ladega', '[email protected]', '2008-07-18'), Quote Link to comment https://forums.phpfreaks.com/topic/115538-generating-id/ Share on other sites More sharing options...
.josh Posted July 19, 2008 Share Posted July 19, 2008 That's not code that's a sql dump. Quote Link to comment https://forums.phpfreaks.com/topic/115538-generating-id/#findComment-593977 Share on other sites More sharing options...
ratcateme Posted July 19, 2008 Share Posted July 19, 2008 can you create a new field to store the EN or SE Quote Link to comment https://forums.phpfreaks.com/topic/115538-generating-id/#findComment-593993 Share on other sites More sharing options...
MasterACE14 Posted July 19, 2008 Share Posted July 19, 2008 I use this in one of my games to create a Unique ID for each player when they register. <?php $time = time(); $uniqid = chr(rand(ord('a'),ord('z'))).chr(rand(ord('a'),ord('z'))).$time; ?> and the output of that is this for example: rm1215682605 Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/115538-generating-id/#findComment-594002 Share on other sites More sharing options...
cooldude832 Posted July 19, 2008 Share Posted July 19, 2008 the primary key isn't sufficient why? Quote Link to comment https://forums.phpfreaks.com/topic/115538-generating-id/#findComment-594005 Share on other sites More sharing options...
cooldude832 Posted July 19, 2008 Share Posted July 19, 2008 rereading your post you should carry into the database the Form from which it processed (use a hidden form input with the Form'sID number) and leave the primary key as is. Then have a secondary table that links all formIDs to the form names and location Quote Link to comment https://forums.phpfreaks.com/topic/115538-generating-id/#findComment-594024 Share on other sites More sharing options...
Third_Degree Posted July 19, 2008 Share Posted July 19, 2008 I use this in one of my games to create a Unique ID for each player when they register. <?php $time = time(); $uniqid = chr(rand(ord('a'),ord('z'))).chr(rand(ord('a'),ord('z'))).$time; ?> and the output of that is this for example: rm1215682605 Regards ACE lots of code! uniqid( ) ? Quote Link to comment https://forums.phpfreaks.com/topic/115538-generating-id/#findComment-594025 Share on other sites More sharing options...
I-AM-OBODO Posted July 23, 2008 Author Share Posted July 23, 2008 Helo. How do i insert letters on my unique id. I mean i designed a form that a user fills to make a request. I want each request a user makes it should have its own unique transaction ID. and since i have more than just one form that needs be filled (on other pages there's form for other transactions), i want to adentify each form with a unique number exaple EN001 for a particular form and SE001 for another form etc. I tried but dont know a way out of this. These my code: CREATE TABLE `transactions` ( `tranxID` int(255) NOT NULL auto_increment, `product_code` varchar(50) NOT NULL, `trans_type` varchar(50) NOT NULL, `pay_type` varchar(50) NOT NULL, `fname` varchar(50) NOT NULL, `lname` varchar(50) NOT NULL, `address` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, `date_of_order` date NOT NULL, PRIMARY KEY (`tranxID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; -- -- Dumping data for table `transactions` -- INSERT INTO `transactions` (`tranxID`, `product_code`, `trans_type`, `pay_type`, `fname`, `lname`, `address`, `email`, `date_of_order`) VALUES (1, '12345', 'single', 'cheque', 'chidi', 'obodo', '31 ladega', '[email protected]', '2008-07-18'), Still cant get thing done. Anyone with any idea how it can get done cos am having head-ache trying to get it done. I want letter before the tranxID (i.e ES0012) thanks Quote Link to comment https://forums.phpfreaks.com/topic/115538-generating-id/#findComment-598094 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.