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!

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.

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.