suckablesausage Posted March 30, 2006 Share Posted March 30, 2006 hello gurus =)i was wondering how to generate a unique ID so it can be put in mysql. am i making sense? Quote Link to comment Share on other sites More sharing options...
txmedic03 Posted March 30, 2006 Share Posted March 30, 2006 [code]mysql_query("CREATE TABLE IF NOT EXISTS `tablename` (`id` int(11) not null auto_increment, `field1` text(80) not null, `field2` text(80) not null, primary key (id))") or die(mysql_error());[/code]The id field will be incremented automatically so it will be unique. If you use phpMyAdmin or something of that nature you can set all of these things while creating the table through the user interface. Quote Link to comment Share on other sites More sharing options...
Plazman65 Posted March 30, 2006 Share Posted March 30, 2006 [!--quoteo(post=360191:date=Mar 30 2006, 03:07 PM:name=jireh)--][div class=\'quotetop\']QUOTE(jireh @ Mar 30 2006, 03:07 PM) [snapback]360191[/snapback][/div][div class=\'quotemain\'][!--quotec--]hello gurus =)i was wondering how to generate a unique ID so it can be put in mysql. am i making sense?[/quote]oh oh I think I can answer this one for ya! (Im new myself). If you mean you want a unique number for lets say a user name I use the Auto-Increment.Michelle Quote Link to comment Share on other sites More sharing options...
suckablesausage Posted March 30, 2006 Author Share Posted March 30, 2006 ah yes i got it to work! man youre so smart =P i have another quick question. the id is 2 ,3 ,4 but is there a way to make it 00002, 00003, 00004? =) Quote Link to comment Share on other sites More sharing options...
Barand Posted March 31, 2006 Share Posted March 31, 2006 Define the id as[code]id int(5) zerofill not null auto_increment[/code] Quote Link to comment Share on other sites More sharing options...
suckablesausage Posted March 31, 2006 Author Share Posted March 31, 2006 wow!! thank you!! gosh i love this forum :) Quote Link to comment 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.