Jump to content

how to edit records from form list??


dazzathedrummer

Recommended Posts

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

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.

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??

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.

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.