Hi all,
I have a data base with the following table:
---member_data---
id ^ mid fieldname fieldvalue
1 - 2 - applicant - Seth Smith
2 - 4 - firstname - Chris
3 - 4 - lastname - Cooper
4 - 7 - full_name - Joey Jones
5 - 7 - occupation - Programmer
6 - 7 - phone - 800-555-1212
And below is a snippet that I use to display the selected members data for editing
<table>
<tr>
<td>Name:</td>
<td>Value:</td>
</tr>
<?php
$query = "SELECT * FROM member_data WHERE mid='$mid'";
$result= mysql_query($query);
while($row = mysql_fetch_array($result)) {
$fieldname = $row["fieldname"];
$fieldvalue = $row["fieldvalue"];
?>
<tr>
<td><input type="text" name="<?php echo $fieldname;?>" value="<?php echo $fieldname;?>"></td>
<td><input type="text" name="<?php echo $fieldvalue;?>" value="<?php echo $fieldvalue;?>"></td>
<?php } ?>
</tr>
</table>
My question is:
- using the Db example above:
- lets say Ive selected mid#7 (member id 7) to edit which is displayed using the snippet code from above.
- once displayed how do I edit mid#7 given the fact that mid#7 is located on 3 seperate rows from the same table?
Thank you,
Dave
*ALSO - I tried the snippet below which did Not work.
foreach($_POST as $key => $val) {
$sql = "UPDATE member_data SET fieldname='$key', fieldvalue='$val' WHERE mid='$mid'";
$result = mysql_query($sql);
}