mc_keny Posted November 21, 2007 Share Posted November 21, 2007 hey ppl ok here is the thing i creat a data base with these field id,name,pass and register form where i insert the specify user name and pass mysql_query("INSERT INTO mc_users (name,pass) VALUES ('mc_keny','$pass')");[/code]i want mc_keny to have id 1 but instead it got id 3 any can help me pls Link to comment Share on other sites More sharing options...
Ingolme Posted November 21, 2007 Share Posted November 21, 2007 That can only mean one thing:id has AUTO_INCREMENT activated and you had some rows in the database before, it doesn't matter if you deleted them or not. Link to comment Share on other sites More sharing options...
mc_keny Posted November 21, 2007 Author Share Posted November 21, 2007 OK BRO I HAVE THE LIKE THIS ID FIRST NAME SECOND PASS THIRD, WHAT MUST I DO DEACTIVATE AUTO INCREMENT TO MAKE RECORD IN ORDER Link to comment Share on other sites More sharing options...
Ingolme Posted November 21, 2007 Share Posted November 21, 2007 Well, the table is created already. You can go modify the table with PHPmyAdmin if you want, and if not then drop that table and create a new one. If AUTO_INCREMENT isn't activated you'll need to go increasing the ids manually.What I'd do in that case is check the highest existant ID in the table and sum 1 to it and put it in the new register. Link to comment Share on other sites More sharing options...
mc_keny Posted November 21, 2007 Author Share Posted November 21, 2007 thanks bro its recording in random number example your the second member the user id shows 4 etc Link to comment Share on other sites More sharing options...
justsomeguy Posted November 21, 2007 Share Posted November 21, 2007 It's not random, it's the next number available. If you insert a new row with an ID of 4 that means that it already used IDs 1, 2, and 3 for other rows. Even if you delete a row it will not reset the autoincrement value. So you can insert 2 rows, then delete them, then insert another and the new row will have an ID of 3. You can delete that one and add a new one and, even though it's the only one there, it has an ID of 4. It's not random, it's sequential. If you really want to reset the autoincrement value to something else (which is never necessary, and may even be a bad idea), you can use an ALTER TABLE statement.http://dev.mysql.com/doc/refman/5.0/en/alter-table.html To change the value of the AUTO_INCREMENT counter to be used for new rows, do this: ALTER TABLE t2 AUTO_INCREMENT = value; Link to comment Share on other sites More sharing options...
Synook Posted November 22, 2007 Share Posted November 22, 2007 You can also query "TRUNCATE mc_users" that will remove all records and reset the auto_increment counter to 1. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.