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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.