2010-04-20 6 views
0

J'ai ce formulaire html qui a des options:Comment comparer une chaîne avec une valeur d'option

<tr> 
<td width="30" height="35"><font size="3">*List:</td> 
<td width="30"><input name="specific" type="text" id="specific" maxlength="25" value=""> 
</td> 

<td><font size="3">*By:</td> 
<td> 
    <select name="general" id="general"> 
     <font size="3"> 
     <option value="YEAR">Year</option> 
     <option value="ADDRESS">Address</option> 


    </select></td></td> 
    </tr> 

Et je suis en train d'avoir cela comme l'action de forme:

if ('{$_POST["ADDRESS"]}'="ADDRESS") 

qui comparez si la valeur de l'option dans le formulaire html correspond au mot "Address". Si elle correspond alors il exécutera cette requête:

$saddress= mysql_real_escape_string($_POST['specific']);<--this is the input form where the user will put the specific address to search. 

mysql_query("SELECT * FROM student WHERE ADDRESS='$saddress'"); 

S'il vous plaît je besoin d'aide ici, je pense que son tort: ​​

if ('{$_POST["ADDRESS"]}'="ADDRESS") 

Répondre

3
if($_POST['general'] == 'ADDRESS') 
+0

merci, vous êtes un épargnant de vie. – user225269

0
$test=strcmp($_POST['general'],"ADDRESS"); 
if($test==0) 
{ 
    //Here you can write your operations. 
} 
Questions connexes