dazzathedrummer Posted March 30, 2010 Share Posted March 30, 2010 Hi, I have a php 'gig' list http://www.the-guards.org.uk/private/giglist_private.php that I have also written a basic (no validation yet) entry form for http://www.the-guards.org.uk/private/giglist_private_entry.php I would like to be able to have members 'edit' entries on the list by clicking the 'edit' button that I have on each record. When the 'edit' button is pressed I would like the user to be taken back to the entry form with the selected record shown in the form for editing - how do I go about this. I understand the principle - populate the form with the values of the fields in the record where the row ID = 'x' and then update table where row ID = 'x'. but i'm unsure how to go about coding this. any help would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/196970-how-to-edit-records-from-form-list/ Share on other sites More sharing options...
trq Posted March 30, 2010 Share Posted March 30, 2010 I understand the principle - populate the form with the values of the fields in the record where the row ID = 'x' and then update table where row ID = 'x'. but i'm unsure how to go about coding this. I'm not sure how you could be stuck. You just described the process, have you tried coding it? The biggest part of learning to program is learning to break your problems into logical steps. Link to comment https://forums.phpfreaks.com/topic/196970-how-to-edit-records-from-form-list/#findComment-1034028 Share on other sites More sharing options...
dazzathedrummer Posted March 30, 2010 Author Share Posted March 30, 2010 ok, yeah I know - slight amount of lazyness haha. so, do I need to capture $_post records for the selected db record and then set them as the form 'values' on the entry form? if so, how do I get the ID of the particular record that i'm selecting - that's what's confusing me?? Link to comment https://forums.phpfreaks.com/topic/196970-how-to-edit-records-from-form-list/#findComment-1034032 Share on other sites More sharing options...
trq Posted March 30, 2010 Share Posted March 30, 2010 As you are creating this list, you need to store the id number of each record within a hidden form element or something. That way, when the button submits the form to the next page, you will know which record was clicked on. You can then use this id to populate the actual detail form. Link to comment https://forums.phpfreaks.com/topic/196970-how-to-edit-records-from-form-list/#findComment-1034036 Share on other sites More sharing options...
dazzathedrummer Posted March 30, 2010 Author Share Posted March 30, 2010 Ok i'm getting somewhere now! I've managed to get the list to echo the ID number in the entry form (although it wont do it if the ID form element is hidden??). I'm just wondering if its best to query the db in the entry form to display the data and then update it - or 'post' the data into the form from the list and then update based on the ID number. Am I right in thinking that the later would be simpler as it doesn't involve querying the db? Link to comment https://forums.phpfreaks.com/topic/196970-how-to-edit-records-from-form-list/#findComment-1034054 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.