Jump to content

Use result from xhtml select function


FoxIII
 Share

Recommended Posts

Hi all,I have been tearing my hair out over this one. What I have is a select function similar to below;<select> <option value="book">Book Title</option> <option value="author">Author</option> <option value="genre">Genre</option></select>I also have a text box allowing a user to enter either a book title, author or genre depending on which selection they make, and then direct to the appropriate page when they click a search button.What I am having problems with, is finding a way to use the select result/index in a way that would allow me to do this.So for example, if a person selects 'Genre' from the drop down list, and then types 'horror' in the text box, when they click search, it will search my sql database for all of the books with the genre 'horror' and display the results.Thanks in advance.

Link to comment
Share on other sites

Yes, I have the database set up and I can search via search boxes which I currently have set up, but they are for each of the subjects mentioned above which work fine, but I just can't seem to work out how to do the same from a dropdown box.

Link to comment
Share on other sites

would you just append an extra valued pair to the search query to return based on the the drop down? Maybe something where you combine the search and the drop down into one form, and based on what is submitted (genre and a search) you search by genre. If there's only a value in the search box, then only filter by the submitted text.

Link to comment
Share on other sites

Maybe something where you combine the search and the drop down into one form, and based on what is submitted (genre and a search) you search by genre
This is what I am attempting, but I cannot see how this would be done.
Link to comment
Share on other sites

<select name="something"><option value="..."> ... </option><option value="..."> ... </option></select>

On the server side you can receive the value under:$_POST['something'];

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...