This really could go in three different sections – XHTML, PHP, and SQL. I chose this section because I need help with the PHP aspect of the code rather than the actual SQL query or drop down menu.
What I have is a drop down menu that will contain five different options:
[code=html]<select>
<option value =”option1″ selected=”selected”>option1</option>
<option value =”option2″>option2</option>
<option value =”option3″>option3</option>
<option value =”option4″>option4</option>
<option value =”option5″>option5</option>
</select>
I also have a textbox which the user will use to type in a query and search for a person from a database. Now, each person that is in the database has a category beside their name. We can call these categories as option1, option2, option3, option4, or option5. In other words I have a column in my database which contains a category and then another column which contains a person’s name.
What I’d like to be able to do is to allow the user to pick which category they would like to search through before actually clicking the search button. They would pick through a drop-down menu that’s been created by the above code using XHTML.
What would the PHP code for something like that look like?
I would imagine that the best way to tackle this would be by using an IF statement in a sense that if option1 was chosen then perform sqlQuery1 and if option2 was selected then perform sqlQuery2 and so on for all five of them; where each query would do a search through only the category that was selected using the drop-down menu.
I hope that’s enough information for someone to give me a few pointers.
Thank you in advance!