i have a drop down list menu in one of form and when the user selects a category i need to write a sql statement to get the details from the catergory selected. Eg: When the user selects option 1,the table 1 should be displayed if the user selects option 2 the table 2 must be displayed. i need to know is there a way that i can pass the option value to the sql query rathe than using if else statemets like, select * from <option selected>
That doesn't work $result = mysql_query("SELECT * FROM members WHERE last=$last AND first=$first"); i need to make the members dynamic.. if the user selects 1 load the table 1 and display the content across the complete site if the user selects 2,load the table 2 and display the content across the complete site
$query = "SELECT * FROM " . mysql_real_escape_string($optionselected) . "WHERE last=$last AND first=$first"; $result = mysql_query($query); PHP: Why doesn't that work?