i'm trying to make a form that will edit the value of a field in a database but first i want the user to see the value that's there... so i made a listbox of items... when the user clicks on an item, it's value shows up in a textbox .... now when i post the form only the value of the textbox is sent ...
what i want to do is to send it's id also with it so i can edit the database this is my code:
<?php
if( isset($_POST['edit']) && $_POST['edit'] == "edit" ){
$sql = "UPDATE global_options SET option_value = '" . $_POST['option_value'] . "' WHERE id = ?????";
$result = mysql_query($sql)
or die('<b>Could not edit option:</b>' . mysql_error());
}//end if
?>
<FORM action="<?php $_SERVER['PHP_SELF']; ?>" method="POST" name="global_options">
<FIELDSET><LEGEND>Edit Options</LEGEND>
<TABLE border="0" cellpadding="3">
<TR>
<TD>Options:</TD>
<TD colspan="2">
<SELECT name="current_option" size="7" onchange="document.getElementById('theid').value=this.value">
<?php
$sql = "SELECT global_options.id, global_options.option_value, options.option_name FROM global_options, options " .
"WHERE global_options.option_id = options.id ORDER BY options.option_name";
$result = mysql_query($sql)
or die('<b>Could not get global options:</b>' . mysql_error());
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result)){
echo "<option value=\"{$row['option_value']}\"";
echo ">{$row['option_name']}</option>\n";
}//end while
}//end if
?>
</select>
</TD>
</TR>
<TR><TD>Value: </TD><TD><INPUT type="text" name="option_value" id="theid"></TD></TR>
<TR>
<TD colspan="2" align="center">
<INPUT type="submit" value="edit" name="edit">
</TD></TR>
</TABLE>
</FIELDSET>
any ideas?