Forums

PHP

This topic is locked

Update Record

Posted 29 Jan 2007 00:41:38
1
has voted
29 Jan 2007 00:41:38 . . posted:
I know that update is probably the wrong terminology in SQL. But Insert doesn't seem to be right either. This is the problem.

I have a PHP MySql Database that has 1 table with 30 fields.. I have created a form that a user enters in the information and a 9digit primary key and posts it to the database. The user needs to add new information into three text area fields every week and also upload files exactly like a forum or message board..When I submit the form that I made it submits it as a new record, but can’t because the primary key makes a SQL error “duplicate key”. I need this form to recognize the record and write the text to the record. And what is it called.

Replies

Replied 29 Jan 2007 02:04:33
29 Jan 2007 02:04:33 Alan C replied:
You need to make your form so that it first reads the appropriate record from the database, inserting the values from the fields into the textfields so that the user can see them. The user can now change the fields, then when they click the submit button you do an update.

You keep the primary key in a hidden field so that it can be submitted back.

If you wanted you could echo the record details back as text and only put the updateable fields into text boxes.

As far as sql goes, INSERT is the action of putting a whole new record into the database and UPDATE is the process of changing anything that is already in a table.
Replied 30 Jan 2007 03:01:11
30 Jan 2007 03:01:11 . . replied:
Thank you that works.

Reply to this topic