[web] Editing a blog post

Started by
1 comment, last by Sonnenblume 17 years, 9 months ago
Ive written a little blogging script in PHP & MySql thats been running away quite happily until I decided to improve it. I basically want to add additional functionality, such as the ability to edit and delete entries. And this is what is causing me the problem. As it stands, all of my entries are laid on on a standard html page. What im looking to achieve is to have an 'edit' button at the corner of each entry, and when its clicked, the original text is loaded into a form for me to ammend and resubmit. I know how to load the text into a form and resubmit it. But what I cant seem to figure out is how to identify which entry I want to edit. I know that I need to search for a specific value of the primary key(entryID) and edit that row, but I dont know how to return that value automatically once the 'edit' button has been clicked. I thought that I would need to assign the entryID to a variable, which will be called when the edit button is hit, but I dont know how identify the entryID in the first place without having to create a search script.
Advertisement
If I understand you correctly, what you need is a hidden form value.

Just add this to your HTML form that's dynamically generated in response to the user asking to edit a post:
<input type="hidden" name="entryid" value="[the entry's ID]">

Then, when the form is submitted, this entry ID is received in the script just like any other form field.

Hidden fields
ah ha!

I did think of using a form, but I didnt realise you could hide them.

Cheers :)

This topic is closed to new replies.

Advertisement