Forum Articles
  Welcome back Join CF
You are here You are here: Home | Forum | Take a look at this

You are currently viewing our boards as a guest which gives you limited access to view most of the discussions, articles and other free features. By joining our Virgin Media community you will have full access to all discussions, be able to view and post threads, communicate privately with other members (PM), respond to polls, upload your own images/photos, and access many other special features. Registration is fast, simple and absolutely free so please join our community today.


Welcome to Cable Forum
Go Back   Cable Forum > Computers & IT > Internet Discussion
Register FAQ Community Calendar

Help (again) ...
Reply
 
Thread Tools
Old 03-07-2004, 12:22   #1
Bifta
Inactive
 
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
Bifta has a nice shiny starBifta has a nice shiny star
Bifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny star
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
Bifta is offline   Reply With Quote
Advertisement
Old 03-07-2004, 12:32   #2
Richard M
Inactive
 
Join Date: Jun 2003
Location: Los Angeles, CA
Age: 47
Posts: 6,343
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
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>
Richard M is offline   Reply With Quote
Old 03-07-2004, 12:40   #3
Bifta
Inactive
 
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
Bifta has a nice shiny starBifta has a nice shiny star
Bifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny star
Re: Help (again) ...

Quote:
Originally Posted by Richard M
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>
Must have missed that heh, anyway it's now:

<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)
Bifta is offline   Reply With Quote
Old 03-07-2004, 12:49   #4
Mr_love_monkey
Inactive
 
Mr_love_monkey's Avatar
 
Join Date: Jun 2003
Location: London way
Age: 50
Services: Sarcasm
Posts: 8,376
Mr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny stars
Mr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny stars
Re: Help (again) ...

if you're using a database can't you just have it so that no preference uses a wildcard instead '%'?
Mr_love_monkey is offline   Reply With Quote
Old 03-07-2004, 12:50   #5
Bifta
Inactive
 
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
Bifta has a nice shiny starBifta has a nice shiny star
Bifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny star
Re: Help (again) ...

Quote:
Originally Posted by Mr_love_monkey
if you're using a database can't you just have it so that no preference uses a wildcard instead '%'?
Ohh, let me give that a try.

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.
Bifta is offline   Reply With Quote
Old 03-07-2004, 12:58   #6
Mr_love_monkey
Inactive
 
Mr_love_monkey's Avatar
 
Join Date: Jun 2003
Location: London way
Age: 50
Services: Sarcasm
Posts: 8,376
Mr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny stars
Mr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny stars
Re: Help (again) ...

What are you using to do this?
Mr_love_monkey is offline   Reply With Quote
Old 03-07-2004, 12:59   #7
Richard M
Inactive
 
Join Date: Jun 2003
Location: Los Angeles, CA
Age: 47
Posts: 6,343
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
Re: Help (again) ...

Quote:
Originally Posted by Bifta
Must have missed that heh, anyway it's now:

<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)
No, what you'll need is this...
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:
<?php
if (isset($_GET['furnishing'])) {
$preference = $_GET['furnishing'];
$dbconnect = mysql_connect("localhost", "username", "password");
$dbname = "database name";
$tablename = "table name";

// If the "furnishing" field is empty (i.e. "") then do this:
if (empty($furnishing)) {
if (!
$dbconnect) {
echo 
mysql_error();
exit;
}
if (!
mysql_select_db($dbname)) {
echo 
mysql_error();
exit;
}
$sql = mysql_query("SELECT * FROM `$tablename`");
if (!
$sql) {
echo 
mysql_error();
exit;
}
while (
$sql_data = mysql_fetch_array($sql))
{
$price = $sql_data['price'];
// etc for each field you need
echo "Price: " . $price . "<br />";
}
mysql_free_result($sql);
mysql_close($dbconnect);
}

// If the "furnishing" field contains a value then do this:
else {
if (!
$dbconnect) {
echo 
mysql_error();
exit;
}
if (!
mysql_select_db($dbname)) {
echo 
mysql_error();
exit;
}
$sql = mysql_query("SELECT * FROM `$tablename` WHERE furnishing='$furnishing'");
if (!
$sql) {
echo 
mysql_error();
exit;
}
while (
$sql_data = mysql_fetch_array($sql))
{
$price = $sql_data['price'];
// etc for each field you need
echo "Price: " . $price . "<br />";

}
mysql_free_result($sql);
mysql_close($dbconnect);
}
}
?>
I haven't tested this but it should work.
Richard M is offline   Reply With Quote
Old 03-07-2004, 13:23   #8
Bifta
Inactive
 
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
Bifta has a nice shiny starBifta has a nice shiny star
Bifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny star
Re: Help (again) ...

Quote:
Originally Posted by Richard M
No, what you'll need is this...
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:
<?php
if (isset($_GET['furnishing'])) {
$preference = $_GET['furnishing'];
$dbconnect = mysql_connect("localhost", "username", "password");
$dbname = "database name";
$tablename = "table name";

// If the "furnishing" field is empty (i.e. "") then do this:
if (empty($furnishing)) {
if (!
$dbconnect) {
echo 
mysql_error();
exit;
}
if (!
mysql_select_db($dbname)) {
echo 
mysql_error();
exit;
}
$sql = mysql_query("SELECT * FROM `$tablename`");
if (!
$sql) {
echo 
mysql_error();
exit;
}
while (
$sql_data = mysql_fetch_array($sql))
{
$price = $sql_data['price'];
// etc for each field you need
echo "Price: " . $price . "<br />";
}
mysql_free_result($sql);
mysql_close($dbconnect);
}

// If the "furnishing" field contains a value then do this:
else {
if (!
$dbconnect) {
echo 
mysql_error();
exit;
}
if (!
mysql_select_db($dbname)) {
echo 
mysql_error();
exit;
}
$sql = mysql_query("SELECT * FROM `$tablename` WHERE furnishing='$furnishing'");
if (!
$sql) {
echo 
mysql_error();
exit;
}
while (
$sql_data = mysql_fetch_array($sql))
{
$price = $sql_data['price'];
// etc for each field you need
echo "Price: " . $price . "<br />";

}
mysql_free_result($sql);
mysql_close($dbconnect);
}
}
?>
I haven't tested this but it should work.
Cheers, that would be a bit tough to fit around my current queries though, what might be easier (if I had ANY clue how to do it) is to stop "furnishing" appearing in the URL string completely if they select "No Preference", must be some way of doing this with PHP in the actual form.
Bifta is offline   Reply With Quote
Old 03-07-2004, 13:35   #9
Mr_love_monkey
Inactive
 
Mr_love_monkey's Avatar
 
Join Date: Jun 2003
Location: London way
Age: 50
Services: Sarcasm
Posts: 8,376
Mr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny stars
Mr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny starsMr_love_monkey has a pair of shiny stars
Re: Help (again) ...

Quote:
Originally Posted by Bifta
(if I had ANY clue how to do it) is to stop "furnishing" appearing in the URL string completely if they select "No Preference", must be some way of doing this with PHP in the actual form.
hmm.. well at the risk of using a sledgehammer to crack a walnut...

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
Mr_love_monkey is offline   Reply With Quote
Old 03-07-2004, 13:36   #10
Richard M
Inactive
 
Join Date: Jun 2003
Location: Los Angeles, CA
Age: 47
Posts: 6,343
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
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:
if (empty($_GET['furnishing'])) {
/* if the value in the URL is empty like:
http://www.site.com/results.php?furnishing=
then do something here...
*/
}
elseif (!empty(
$_GET['furnishing'])) {
/* if the a value for "furnishing" passed in the URL is like:
http://www.site.com/results.php?furnishing=Fully+Furnished
then do something different
*/
} 
Richard M is offline   Reply With Quote
Old 03-07-2004, 13:37   #11
Bifta
Inactive
 
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
Bifta has a nice shiny starBifta has a nice shiny star
Bifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny star
Re: Help (again) ...

Quote:
Originally Posted by Mr_love_monkey
hmm.. well at the risk of using a sledgehammer to crack a walnut...

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
Unfortunately the way it's layed out wouldn't allow me to do that, thanks though.

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
Bifta is offline   Reply With Quote
Old 03-07-2004, 13:40   #12
Bifta
Inactive
 
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
Bifta has a nice shiny starBifta has a nice shiny star
Bifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny star
Re: Help (again) ...

Quote:
Originally Posted by Richard M
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:
if (empty($_GET['furnishing'])) {
/* if the value in the URL is empty like:
[url]http://www.site.com/results.php?furnishing=[/url]
then do something here...
*/
}
elseif (!empty(
$_GET['furnishing'])) {
/* if the a value for "furnishing" passed in the URL is like:
[url]http://www.site.com/results.php?furnishing=Fully+Furnished[/url]
then do something different
*/
} 
Heh, that's almost what I said It's the "do something here" bit that baffles me (sorry, I still know very little about PHP and it's probably very infuriating for people trying to help me)
Bifta is offline   Reply With Quote
Old 03-07-2004, 13:46   #13
Richard M
Inactive
 
Join Date: Jun 2003
Location: Los Angeles, CA
Age: 47
Posts: 6,343
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
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'");
Richard M is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 22:49.


Server: lithium.zmnt.uk
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum