izzy Posted May 31, 2006 Share Posted May 31, 2006 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 databaseand the pulldown would look like thisfor example:make a selection...0 - 1010 - 2020 - 3030 - 4040 - 5050 - morehow can i write the script to do this.What would be different than a normal search script? Quote Link to comment https://forums.phpfreaks.com/topic/10839-making-a-search-selection-box/ Share on other sites More sharing options...
appeland Posted May 31, 2006 Share Posted May 31, 2006 Hello,are you looking for help with the build of the select list out of the database or the search function ?Regards,Andi Quote Link to comment https://forums.phpfreaks.com/topic/10839-making-a-search-selection-box/#findComment-40501 Share on other sites More sharing options...
lelnguye Posted May 31, 2006 Share Posted May 31, 2006 [!--quoteo(post=378644:date=May 31 2006, 04:53 AM:name=izzy)--][div class=\'quotetop\']QUOTE(izzy @ May 31 2006, 04:53 AM) [snapback]378644[/snapback][/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 databaseand the pulldown would look like thisfor example:make a selection...0 - 1010 - 2020 - 3030 - 4040 - 5050 - morehow 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 Quote Link to comment https://forums.phpfreaks.com/topic/10839-making-a-search-selection-box/#findComment-40502 Share on other sites More sharing options...
izzy Posted May 31, 2006 Author Share Posted May 31, 2006 [!--quoteo(post=378646:date=May 31 2006, 12:09 PM:name=appeland)--][div class=\'quotetop\']QUOTE(appeland @ May 31 2006, 12:09 PM) [snapback]378646[/snapback][/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\" /] Quote Link to comment https://forums.phpfreaks.com/topic/10839-making-a-search-selection-box/#findComment-40509 Share on other sites More sharing options...
appeland Posted May 31, 2006 Share Posted May 31, 2006 Hello,here you go[code]SELECT <column_name> FROM <table_name> WHERE (<column_name> BETWEEN value1 AND value2)[/code]Cheers,Andi Quote Link to comment https://forums.phpfreaks.com/topic/10839-making-a-search-selection-box/#findComment-40512 Share on other sites More sharing options...
izzy Posted May 31, 2006 Author Share Posted May 31, 2006 [!--quoteo(post=378657:date=May 31 2006, 12:43 PM:name=appeland)--][div class=\'quotetop\']QUOTE(appeland @ May 31 2006, 12:43 PM) [snapback]378657[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hello,here you go[code]SELECT <column_name> FROM <table_name> WHERE (<column_name> BETWEEN value1 AND value2)[/code]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\" /] Quote Link to comment https://forums.phpfreaks.com/topic/10839-making-a-search-selection-box/#findComment-40530 Share on other sites More sharing options...
appeland Posted May 31, 2006 Share Posted May 31, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/10839-making-a-search-selection-box/#findComment-40533 Share on other sites More sharing options...
izzy Posted May 31, 2006 Author Share Posted May 31, 2006 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 20naam: 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... Quote Link to comment https://forums.phpfreaks.com/topic/10839-making-a-search-selection-box/#findComment-40547 Share on other sites More sharing options...
izzy Posted May 31, 2006 Author Share Posted May 31, 2006 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\" /] Quote Link to comment https://forums.phpfreaks.com/topic/10839-making-a-search-selection-box/#findComment-40594 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.