manalnor Posted March 1, 2011 Share Posted March 1, 2011 Hello dear friends, say i've database table with (id,name) and want to add more informations by insert new names within an file for example has $q1 = "INSERT INTO `mytable` VALUES (???,name1); mysql_query($q1) or die(mysql_error()." at row ".__LINE__); $q2 = "INSERT INTO `mytable` VALUES (???,name2); mysql_query($q2) or die(mysql_error()." at row ".__LINE__); ect..... how then it automatic detect the last id to go on after it ? some says use mysql_insert_id but i didn't understand how to apply it in this way also the example at php.net is bad not explain much please how can i use it thanks Quote Link to comment Share on other sites More sharing options...
ccmcs Posted March 1, 2011 Share Posted March 1, 2011 depends what the format of your ID is but can you not just use the AUTO_INCREMENT feature on the id column of the DB? Quote Link to comment Share on other sites More sharing options...
manalnor Posted March 1, 2011 Author Share Posted March 1, 2011 depends what the format of your ID is but can you not just use the AUTO_INCREMENT feature on the id column of the DB? yes thank you so much i've forgot to mention this it is normal auto_increment (number 1,2,3,4,5--->ect) `id` int(3) NOT NULL auto_increment, so any way how to apply it 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.