Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/267472-help-creating-url/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/267472-help-creating-url/#findComment-1371759
Share on other sites

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";

Link to comment
https://forums.phpfreaks.com/topic/267472-help-creating-url/#findComment-1371769
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.