0

Hi,
I have been trying to develope a code for updating a table if a specific option is selected from a dropdown list the following is a select option code.

<select name="x_visittype" id="x_visittype"><? echo $visittype;?>
	<option>Select</option>
	<option id="x_visittype">ADM</option>
	<option id="x_visittype">NE</option>
	<option id="x_visittype"><?php echo($opt);?></option>
        <option id="x_visittype">AC</option>
	<option id="x_visittype">CO</option>
</select>
The logics for the update statement are as follows;
if ($opt="AN")
	{
	$sql="UPDATE samps SET visit1='1' where demographic_id='$demoid'";
    $res = mysql_query($sql) or die(mysql_error());
	}
	elseif($opt="V2")
	{
	$sql="UPDATE samps SET visit2='1' where demographic_id='$demoid'";
	$res = mysql_query($sql) or die(mysql_error());
	}
	elseif($opt="V3")
	{
	$sql="UPDATE samps SET visit3='1' where demographic_id='$demoid'";
	$res = mysql_query($sql) or die(mysql_error());
	}
	elseif($opt='V4')
	{
	
	$sql="UPDATE samps SET visit1='',visit2='',visit3='',visit4='' where demographic_id='$demoid'";
	$res = mysql_query($sql) or die(mysql_error());
	}

How do i intergrate the update statements to ensure that samps table is updated iff $opt is selected.
Currently the table is updated if any of the options is selected.
Thanxs,
Julie

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by nav33n
0

When the form is submitted, get the value of the select box. $selectboxvalue = $_POST;
Then update the table depending upon the value of $selectboxvalue !

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.