Jump to content

Editing database table rows


Nothadoth

Recommended Posts

I have searched this but for some reason I cannot find out how to do this.

I've managed to script the control panel so that I can add things in. Easy: INSERT INTO

However, could someone tell me how to script it so that I can edit a row?
I mean I can select the row from the database and have the data inside of form fields. But when I click submit, how would I make it so that it will edit and replace the row fields with what is in each of the form fields.

Thanks
Link to comment
Share on other sites

[code]
UPDATE phone_tarrifs SET `Name`='newvalue', Tariff='newvalue', Image='newvalue' WHERE id='identifier'
[/code]

Note the id column stipulated in the WHERE clause. You need a unique [i]key[/i] to be able to locate the exact record to update.
Link to comment
Share on other sites

UPDATE phone_tariffs SET Name = '$name', Tariff = '$tariff', Image = '$image';

BUT if you just did that it woudl up date EVERY record in you database so make sure you use the WHERE cluase if you only want to update certain records.

UPDATE phone_tariffs SET Name = '$name', Tariff = '$tariff', Image = '$image' WHERE Id = '$id'

Will ensure you only update the row(s) where Id = the ste value.
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.