FoxIII Posted March 14, 2010 Share Posted March 14, 2010 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 More sharing options...
thescientist Posted March 14, 2010 Share Posted March 14, 2010 have you read about PHP and MySQL? Do you already have a database set up yet? Link to comment Share on other sites More sharing options...
FoxIII Posted March 14, 2010 Author Share Posted March 14, 2010 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 More sharing options...
thescientist Posted March 14, 2010 Share Posted March 14, 2010 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 More sharing options...
FoxIII Posted March 14, 2010 Author Share Posted March 14, 2010 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 genreThis is what I am attempting, but I cannot see how this would be done. Link to comment Share on other sites More sharing options...
Ingolme Posted March 14, 2010 Share Posted March 14, 2010 <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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.