FUNKAM35 Posted August 23, 2012 Share Posted August 23, 2012 Hi, I currently have a url houses.php?province=$province&country=$country&range=1 which for exaple gives houses.php?province=Malaga&country=Spain&range=2 It takes the province and country from the database the range is a range of prices on houses as follows switch ($range) { case 1: $range_message=" valued up to 100,000 €uros "; $where=" province = '$province' AND price <100001 "; break; case 2: $range_message=" valued between 100,000 €uros and 200,000 €uros"; $where=" province = '$province' AND price between 100000 AND 200000 "; break; case 3: $range_message=" valued between 200,000 €uros and 300,000 €uros"; $where=" province = '$province' AND price between 200000 AND 300000 "; break; case 4: $range_message=" valued between 300,000 €uros and 400,000 €uros"; $where=" province = '$province' AND price between 300000 AND 400000 "; break; case 5: $range_message=" valued between 400,000 €uros and 500,000 €uros"; $where=" province = '$province' AND price between 400000 AND 500000 "; break; case 6: $range_message=" valued between 500,000 €uros and 600,000 €uros"; $where=" province = '$province' AND price between 500000 AND 600000 "; break; case 7: $range_message=" valued over 600,000 €uros "; $where=" province = '$province' AND price > 600000 "; break; default: $where= " province = '$province' "; break; } I need the url to be houses.php?province=Malaga&country=Spain&PRICE WHATEVER THE RANGE IS EG 100000-200000 EUROS Please help as to how I do this as just cant get it to work Thanks Quote Link to comment https://forums.phpfreaks.com/topic/267472-help-creating-url/ Share on other sites More sharing options...
Barand Posted August 23, 2012 Share Posted August 23, 2012 houses.php?province=Malaga&country=Spain&pricemin=100000&pricemax=200000 Quote Link to comment https://forums.phpfreaks.com/topic/267472-help-creating-url/#findComment-1371750 Share on other sites More sharing options...
FUNKAM35 Posted August 23, 2012 Author Share Posted August 23, 2012 Thanks Barand tried this but then url displays all properties not just the ones in that price brand?? Quote Link to comment https://forums.phpfreaks.com/topic/267472-help-creating-url/#findComment-1371752 Share on other sites More sharing options...
Barand Posted August 23, 2012 Share Posted August 23, 2012 how are you creating the WHERE clause? Quote Link to comment https://forums.phpfreaks.com/topic/267472-help-creating-url/#findComment-1371757 Share on other sites More sharing options...
FUNKAM35 Posted August 23, 2012 Author Share Posted August 23, 2012 Hi Barand, in the houses page it is currently switch ($range) { case 1: $range_message=" valued up to 100,000 €uros "; $where=" province = '$province' AND price <100001 "; break; case 2: $range_message=" valued between 100,000 €uros and 200,000 €uros"; $where=" province = '$province' AND price between 100000 AND 200000 "; break; case 3: $range_message=" valued between 200,000 €uros and 300,000 €uros"; $where=" province = '$province' AND price between 200000 AND 300000 "; break; case 4: $range_message=" valued between 300,000 €uros and 400,000 €uros"; $where=" province = '$province' AND price between 300000 AND 400000 "; break; case 5: $range_message=" valued between 400,000 €uros and 500,000 €uros"; $where=" province = '$province' AND price between 400000 AND 500000 "; break; case 6: $range_message=" valued between 500,000 €uros and 600,000 €uros"; $where=" province = '$province' AND price between 500000 AND 600000 "; break; case 7: $range_message=" valued over 600,000 €uros "; $where=" province = '$province' AND price > 600000 "; break; default: $where= " province = '$province' "; break; } thanks Quote Link to comment https://forums.phpfreaks.com/topic/267472-help-creating-url/#findComment-1371759 Share on other sites More sharing options...
Barand Posted August 23, 2012 Share Posted August 23, 2012 You aren't using the added country value and you need to have price between $pricemin and $pricemax. edit And why use the now non-existent range value? Quote Link to comment https://forums.phpfreaks.com/topic/267472-help-creating-url/#findComment-1371766 Share on other sites More sharing options...
FUNKAM35 Posted August 23, 2012 Author Share Posted August 23, 2012 Hi, thanks Im using the select country bit further up and the country diplays correctly. Its the min price and max price Im having difficuulty with as I have the price set as $price Quote Link to comment https://forums.phpfreaks.com/topic/267472-help-creating-url/#findComment-1371767 Share on other sites More sharing options...
Barand Posted August 23, 2012 Share Posted August 23, 2012 As I mentioned in my post edit, you are relying on a non-existent range value so it will use the default . Scrap the above switch statement, it's now redundant. $pricemin = intval($_GET['pricemin']); $pricemax = intval($_GET['pricemax']); $range_message = "valued between $pricemin euros and $pricemax euros."; $where = "province='$province' AND price BETWEEN $pricemin AND $pricemax"; Quote Link to comment https://forums.phpfreaks.com/topic/267472-help-creating-url/#findComment-1371769 Share on other sites More sharing options...
FUNKAM35 Posted August 23, 2012 Author Share Posted August 23, 2012 Genius it works, thanks. just having a few teething problems with next page links, im working on these now. thank you so much!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/267472-help-creating-url/#findComment-1371797 Share on other sites More sharing options...
FUNKAM35 Posted August 25, 2012 Author Share Posted August 25, 2012 Thanks Barand, it is up and running perfectly much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/267472-help-creating-url/#findComment-1372288 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.