Jump to content

Insert into auto increment and remember the value?


Recommended Posts

An admin of a site I am creating needs to be able to create members with certain extra authorities, moderators if you will. They will create the members and insert all the details. However, they also need to keep paper records of these moderators with all the details on them. On these paper records is included the ID of the moderator. So I wish to display on screen after the member has been created, the members ID so the admin can make a note of it.

 

This is the query being used (shortened):

$new = mysql_query("INSERT INTO members (ID, name) VALUES (NULL, '$name')");

 

Without again querying the database am I able to find out what the value of the newly created ID is, that NULL value? Google has revealed nothing so far.

 

Thanks for any help,

Joe

ok, you don't insert anything into an auto inc filed - EVER.  You can't retrieve a resultset from running an INPUT statement.  If you want information out of the database you are going to need to run a SELECT on it, so you will need another query.

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.