October 2009
Beginner
408 pages
7h 27m
English
In your form, you added a hidden input to store the entry's ID. This hidden input is what you use to determine whether a form submission is an edit or a new entry.
To make this distinction, you need to check whether $_GET['id'] is empty. If so, the entry is new, and you can proceed as usual. If $_GET['id'] has a value, however, you're editing an entry, and you must use a different query.
You update an entry in the entries table by specifying which fields are being set to which value. Your ID won't change, but the title, url, and entry fields all might, so your query needs to look like this:
UPDATE entries SET title=?, entry=?, url=? WHERE id=? LIMIT 1
This query updates a maximum of one entry in the entries ...
Read now
Unlock full access