View Single Post
Old 01-05-2008, 07:03 PM   #21 (permalink)
Village Idiot
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by Aaron View Post
If you don't want a user to have the same username as another user you set that as the primary key. There is a fine reason for no auto-increment.
Your primary key should only be a number which exists for the sole purpose of being a constant and unique ID number. What if you want to change names?

Quote:
Originally Posted by Aaron View Post
So... How would I have a value start at one, and go up every time a new user registers?
Set the primary key to auto_incriment, every time you insert a row the ID will go up one. Here is a table I used in a recent project.

[code]
CREATE TABLE `users` (
`id` int(9) NOT NULL auto_increment,
`username` varchar(255) NOT NULL,
`mail` varchar(255) NOT NULL,
`pass` varchar(255) NOT NULL,
`rank` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
[/quote]

Create that table in your database and insert a few rows.

Quote:
Originally Posted by Aaron View Post
edit: and why does everyone have this and that as "foo" and "bar" on the explainations? My dad says that all the time and it freaks me out.
Just dummy values, its considered geeky (partially in jest). I just use them because I don't want to spend any time thinking over meaningless values.
__________________

Village Idiot is offline  
Reply With Quote
The Following User Says Thank You to Village Idiot For This Useful Post:
Aaron (01-05-2008)