Hello Friends, I just take a simple form with one select option and one text box i am trying to pass value through variable there are nothing result <form action="employee2.php" method="post" > Search by <select name="select"> <option value="employee_id">Employee Id</option> <option value="employee_name">employee_name</option> </select> Enter : <input type="text" name="employee_name2" /> <input name="submit" type="submit" value="Search" /> </form> if(isset($HTTP_POST_VARS["submit"])) { $employee_id_temp = $HTTP_POST_VARS["select"]; $emp_name = $HTTP_POST_VARS["employee_name2"]; } and query $query = "SELECT * FROM emp_detail WHERE '$employee_id_temp' = '$emp_name'" or die(mysql_error()); or i also try with $query = "SELECT * FROM emp_detail WHERE '".$employee_id_temp."' = '".$emp_name."' " or die(mysql_error()); There are no any result, if you have any idea tell me
1. use $_POST instead of $HTTP_POST_VARS 2. don't name your select box "select" - that's making things confusing 3. are you doing anything with your query besides creating a text string? As it stands, your query doesn't actually do anything. try this: // add code to connect to your db here $query = "SELECT * FROM emp_detail WHERE " . $employee_id_temp . " = '" . $emp_name . "'"; $res = mysql_query($query) or die($query . "<BR><BR>" . mysql_error()); while ($row = mysql_fetch_assoc($res)) { //do something with the row data, like: echo $row[$employee_id_temp]; } Code (markup):
4. Make sure you always sanitise and escape any strings that come from the user before you use them in a database query. Otherwise people can mess with your database in all sorts of awful ways.