Jump to content

Insert if not exist, update if if it does?


Lucky2710

Recommended Posts

Not really.

 

I need for when a user fills in a form. (I'm working on the process script) For the form to take that information and insert the users input into the mysql table. Each user will have his/her own row.

If at any point the user wants to change the information i want them to just be able to fill in the form again and re submit it. All of the resubmitted info needs to override that users original input.

 

So if not exist then insert, if exist then update.

 

(I don't see how your first script does that, i see update if else insert but how ur script decides which to do doesn't appear to be what i need!

Link to comment
Share on other sites

I'm assuming all the users are registered already, and at least have a username, password, and primary key id in the database. If that's the case a regular UPDATE query should be all you need. If the field is empty, it will insert the data, if not, it will overwrite 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.