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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.