I am really struggling here. I have a page on our charity website where a nominated user can update a members record using a straightforward form. The code I am using works but the user has to input all the fields whether or not they need updating. So for example if the firleds were FirstName, Surname ,Role, Address and email and I wanted to change the members email address then the way I am doing it at present all the fields would need to be entered or only the email address would apprear in the record. The update statement and code I using at this stage is:
[code]$id = $_POST[‘member_id’];
$field2 = $_POST[‘FirstName’];
$field3 = $_POST[‘Surname’];
$field4 = $_POST[‘Role’];
$field5 = $_POST[‘Address1’];
$field6 = $_POST[‘Address2’];
$field7 = $_POST[‘Address3’];
$field8 = $_POST[‘Address4’];
$field9 = $_POST[‘PostCode’];
$field10 = $_POST[‘Telephone’];
$field11 = $_POST[‘email’];
if($id){
mysql_query("UPDATE tblMembers SET FirstName='$field2',Surname='$field3',Role='$field4',Address1='$field5',Address2='$field6',Address3='$field7',Address4='$field8',PostCode='$field9',Telephone='$field10',email='$field11' WHERE eventid ='$id'");
}else{}
[/code]
The form I am using is shown in this code:
[code]
Post Code |
My MySQL Database is called: “eachfrie_Events” and the relevant table is called “tblMembers”
Ideally what I would like is a combo box which shows both the member_id and Surname where the user can click on the required member, the form populate with all the fields for that record and when the user changes one of the fields it updates the table without the need to change each field in the record. Can anyone please show me how I can achieve this?