Jump to content


Photo

making a search selection box


  • Please log in to reply
8 replies to this topic

#1 izzy

izzy
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 31 May 2006 - 09:53 AM

I'm making a search section for my site.
What i would like is a pulldown menu were visitors can selct a price range for their search in the database.
I already have a search that works, but now i would like them to be able to search i a price range.

The prices for objects are in my database
and the pulldown would look like this
for example:

make a selection...
0 - 10
10 - 20
20 - 30
30 - 40
40 - 50
50 - more


how can i write the script to do this.
What would be different than a normal search script?

#2 appeland

appeland
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 31 May 2006 - 10:09 AM

Hello,
are you looking for help with the build of the select list out of the database or the search function ?

Regards,
Andi



#3 lelnguye

lelnguye
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 31 May 2006 - 10:12 AM

[!--quoteo(post=378644:date=May 31 2006, 04:53 AM:name=izzy)--][div class=\'quotetop\']QUOTE(izzy @ May 31 2006, 04:53 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I'm making a search section for my site.
What i would like is a pulldown menu were visitors can selct a price range for their search in the database.
I already have a search that works, but now i would like them to be able to search i a price range.

The prices for objects are in my database
and the pulldown would look like this
for example:

make a selection...
0 - 10
10 - 20
20 - 30
30 - 40
40 - 50
50 - more
how can i write the script to do this.
What would be different than a normal search script?
[/quote]


I'm not sure if this is what you're looking for, but you could use select form... for example

<form method="post" action="someaction.php">
<select name="price_range">
<option> 0-10 </option>
...
</select>
<input type="submit" name="submit">

and in your php code you could write

<?

if (isset($_POST['price_range'])) {
$range = $_POST['price_range'];
etc...
}

?>



well... hope this helps

#4 izzy

izzy
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 31 May 2006 - 10:29 AM

[!--quoteo(post=378646:date=May 31 2006, 12:09 PM:name=appeland)--][div class=\'quotetop\']QUOTE(appeland @ May 31 2006, 12:09 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Hello,
are you looking for help with the build of the select list out of the database or the search function ?

Regards,
Andi
[/quote]

I'm looking for help in the search function.
How would i make the database show the objects that are in the selected price range?
I'm not getting it aaarrrrgggg !!! [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /]

#5 appeland

appeland
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 31 May 2006 - 10:43 AM

Hello,here you go
SELECT <column_name> FROM <table_name> WHERE (<column_name> BETWEEN value1 AND value2)
Cheers,
Andi

#6 izzy

izzy
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 31 May 2006 - 11:59 AM

[!--quoteo(post=378657:date=May 31 2006, 12:43 PM:name=appeland)--][div class=\'quotetop\']QUOTE(appeland @ May 31 2006, 12:43 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Hello,here you go
SELECT <column_name> FROM <table_name> WHERE (<column_name> BETWEEN value1 AND value2)
Cheers,
Andi
[/quote]

But there is only one value. isn't there?

for example the earlioer given example...

<form method="post" action="someaction.php">
<select name="price_range">
<option> 0-10 </option>
<option> 10-20 </option>
<option> 20-30 </option>
<option> 30-40 </option>
<option> 40-50 </option>
<option> 50-60 </option>
</select>
<input type="submit" name="submit">

Please keep helpin me and we'll get there [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /]


#7 appeland

appeland
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 31 May 2006 - 12:09 PM

make you select box like this:
<form method="post" action="someaction.php">
<select name="price_range">
<option value="1"> 0-10 </option>
<option value="2"> 10-20 </option>
<option value="3"> 20-30 </option>
<option value="4"> 30-40 </option>
<option value="5"> 40-50 </option>
<option value="6"> 50-60 </option>
</select>
<input type="submit" name="submit">

and then, in the form target you do if's to set the variables of the values, example:
if ($price_range == 1){ $value1="0"; $value2="10"; }
if ($price_range == 2){ $value1="10"; $value2="20"; }
...
then you have the correct value range in the variables and use those in the select.

#8 izzy

izzy
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 31 May 2006 - 12:54 PM

So far i've got this... i'm still doing somethig wrong but nearly there.
keep up the good work... you're really helping me along.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\albinus\search\searchprijsresults.php on line 20
naam:
prijs:



HERE IS THE FORM

<form method="post" action="searchprijsresults.php">
<select name="price_range">
<option value="1"> tot 100.000 </option>
<option value="2"> 100.000-200.000 </option>
<option value="3"> 200.000-300.000 </option>
<option value="4"> 300.000-400.000 </option>
<option value="5"> 400.000-500.000 </option>
<option value="6"> 500.000-600.000 </option>
<option value="7"> 600.000-700.000 </option>
<option value="8"> 700.000-800.000 </option>
<option value="9"> 800.000-900.000 </option>
<option value="10"> 900.000-1.000.000 </option>
<option value="11"> 1.000.000 & meer </option>
</select>
<input type="submit" name="submit">
</form>




// THIS IS THE RESULT PAGE
<?
if ($price_range == 1){ $value1="0"; $value2="100.000"; }
if ($price_range == 2){ $value1="100.000"; $value2="200.000"; }
if ($price_range == 3){ $value1="200.000"; $value2="300.000"; }
if ($price_range == 4){ $value1="300.000"; $value2="400.000"; }
if ($price_range == 5){ $value1="400.000"; $value2="500.000"; }
if ($price_range == 6){ $value1="500.000"; $value2="600.000"; }
if ($price_range == 7){ $value1="600.000"; $value2="700.000"; }
if ($price_range == 8){ $value1="700.000"; $value2="800.000"; }
if ($price_range == 9){ $value1="800.000"; $value2="900.000"; }
if ($price_range == 10){ $value1="900.000"; $value2="1.000.000"; }
if ($price_range == 11){ $value1="1.000.000"; $value2="99.000.000"; }

$prijs_SQL="SELECT * FROM huis WHERE (prijs BETWEEN value1 AND value2)";

// i've also tried $value1 AND $value2

$prijs_result=mysql_query($prijs_SQL);
$result=mysql_fetch_array($prijs_result);

?>

<table width="410" border="0">
<tr>

<span><strong><?php echo $result['naam']?></strong></span>
<td width="350">
<table width="210" border="0">
<tr>
<td width="100">prijs: </td>
<td>
<span><?php echo $result['prijs']?></span>
</td>
</tr>

...AND SO ON...

#9 izzy

izzy
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 31 May 2006 - 03:19 PM

Nearly there... just a little more help.
Please ? [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users