![]() |
Help (again) ...
I'm having trouble with a search form, normally when I click submit it'll encode the URL with the form parameters, e.g.
http://www.url.com/results.php?minpr...sort=Price+ASC The problem I have is with "furnishing" which is a drop down menu <select name="furnishing"> <option value="Furnished">Furnished <option value="Unfurnished">Unfurnished <option value="Part furnished">Part furnished <option value="Furnished to suit">Furnished to suit <option>No preference</option> </select> If I select an option, e.g. "furnished" from the drop down menu, it shows results, if I pick no preference it'll encode the url with "furnishing=" and show no results, is there something I can put in to the results page to show all types of furnishing or is there something I can do to the form to make it work? Thanks |
Re: Help (again) ...
You should really be using the closing </option> tags and put 'selected="selected"' in the default option.
e.g.: <select name="furnishing"> <option value="Furnished">Furnished</option> <option value="Unfurnished">Unfurnished</option> <option value="Part furnished">Part furnished</option> <option value="Furnished to suit">Furnished to suit</option> <option value="No preference" selected="selected">No preference</option> </select> |
Re: Help (again) ...
Quote:
<select name="furnishing"> <option value="Furnished">Furnished</option> <option value="Unfurnished">Unfurnished</option> <option value="Part furnished">Part furnished</option> <option value="Furnished to suit">Furnished to suit</option> <option value="">No preference</option> </select> You see, there is no value in the database for "No Preference", so I want it to just somehow bypass the "furnishing" field somehow, I thought that furnishing= (with nothing after it) would show them all, but .. it doesn't :( which is a bit odd, because if I set one of the other fields to say minbeds= (with nothing after it) it shows all the results. which is probably due to: if ($minprice == "") { $minprice = 0; } in the results page. I just need to get something in there for furnishing (somehow) |
Re: Help (again) ...
if you're using a database can't you just have it so that no preference uses a wildcard instead '%'?
|
Re: Help (again) ...
Quote:
edit: A cunning idea that used to work with an ASP based property search, but for some reason doesn't work with this, still no records shown. :( |
Re: Help (again) ...
What are you using to do this?
|
Re: Help (again) ...
Quote:
Use the HTML that I described in my post, you shouldn't use a blank value but the below code will still work anyway. PHP Code:
|
Re: Help (again) ...
Quote:
|
Re: Help (again) ...
Quote:
What you could do is have the select box outside of the html form, if your layout will allow that, then have an onsubmit javascript coming off the button that grabs the select details and decides to add it in, by dyamically adding an element to your search form. If that makes sense... but it does seem a bit of over kill |
Re: Help (again) ...
It's not really possible to stop the browser sending the "furnishings" value, even if it's empty - other than Javascript but you can't always rely on this.
This PHP code deals with it though: PHP Code:
|
Re: Help (again) ...
Quote:
The only other thing I can think of is to have say "No Preference" set to a value, then the results page does something like if ($furnishing = "whatevervalue") {do something beyond my capabilities to show all furnishing types} If that makes any sense :D |
Re: Help (again) ...
Quote:
|
Re: Help (again) ...
No preference should really be set to a value.
The code I posted first of all will help with that, especially the second part: // If the "furnishing" field contains a value then do this: $sql = mysql_query("SELECT * FROM `$tablename` WHERE furnishing='$furnishing'"); |
| All times are GMT. The time now is 22:57. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum