Php mysql最小和最大价格范围[关闭]

Hi I am wanting to create a page that enables the user to select a min and max price from a drop down menu and be display results from a database in that price range. I have my database set up just not sure where to go next. Ive done research and found this code:

$min = (int)$_GET['min'];
$max = (int)$_GET['max'];

$sql = "Select * from golf_courses where price>=$min and price<=$max";

Is this right to use and how do you set up the select box to link to this php code and the database prices?

Thanks for any help in advance :)

The min and max values will need to be the name attributes of your select elements, like such:

<select name="min">
  <option value="0">None</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  ...
</select>

If you're using a form in the traditional sense (i.e. posting values to a PHP page) then the variables will actually live in $_POST, and you will need to access them there instead of $_GET. If you use the method="GET" attribute/value on your form tag then you can make the request with a GET instead. The basic difference here is whether you want the values to show up in the query string or not. For instance, using method="POST" will take you to example.php, whereas using method="GET" will send you to example.php?min=2&max=3, for instance.