Jump to content

How to use this ! mysql_insert_id


manalnor

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.