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 Link to comment https://forums.phpfreaks.com/topic/229249-how-to-use-this-mysql_insert_id/ 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? Link to comment https://forums.phpfreaks.com/topic/229249-how-to-use-this-mysql_insert_id/#findComment-1181252 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 Link to comment https://forums.phpfreaks.com/topic/229249-how-to-use-this-mysql_insert_id/#findComment-1181254 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.