简体   繁体   English

使用PHP掌握价格范围的价值

[英]Grab the value of price range using PHP

I am working with a similar price range: http://jsfiddle.net/dhana36/b453V/2/ 我正在使用类似的价格范围: http//jsfiddle.net/dhana36/b453V/2/

I would like to be able to grab the values of the minimum and maximum value in a price range from the following javascript function using PHP: 我希望能够使用PHP从以下javascript函数中获取价格范围内的最小值和最大值的值:

 $(function() {
    $( "#slider-range" ).slider({
      range: true,
      min: 0,
      max: 2000,
      values: [ 300, 1000 ],
      slide: function( event, ui ) {
        $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
      }
    });
    $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
      " - $" + $( "#slider-range" ).slider( "values", 1 ) );
  });

Below is what I am trying to achieve: 以下是我要实现的目标:

$p1 = value from minimum value;
$p2 = value from maximum value;
$get_crs = mysql_query("SELECT * FROM products where product_price BETWEEN '$p1' AND '$p2' ORDER BY product_date1");

Hence, my question is as follow: I have a slider, and where the search result is dynamically filter by the minimum and maximum price, my problem is how fill in the following blank: 因此,我的问题如下:我有一个滑块,并且在搜索结果中按最小和最大价格动态过滤的地方,我的问题是如何填写以下空白:

   $p1 = blank;
    $p2 = blank;

Note: If you're curious about how the html portion of it, below is the code: 注意:如果您对它的html部分感到好奇,下面是代码:

  <label for="amount" id="Price">Price Range</label><br>
  <input type="text" id="amount">
</p>
<div id="slider-range"></div>

If you need any clarification, let me know. 如果您需要任何澄清,请告诉我。

 //bul.php or other send methots... <? if($_POST) { $_POST['amount']; $values = str_replace(' ','',$_POST['amount']); $values = str_replace('$','',$values); $values = explode('-',$values); $min = $values[0]; $max = $values[1]; $HTML=''; }; echo $min; echo $max; ?> //html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Başlıksız Belge</title> <script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script> <script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css"> <link rel="stylesheet" type="text/css" href="/css/result-light.css"> <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> <script> $(function() { $('select').change(function(){ $( "#amount" ).val( $('select').val() + $( "#slider-range" ).slider( "values", 0 ) + " - "+ $('select').val() + $( "#slider-range" ).slider( "values", 1 ) ); }) $( "#slider-range" ).slider({ range: true, min: 50, max: 10000, values: [ 75, 300 ], slide: function( event, ui ) { $( "#amount" ).val( $('select').val() + ui.values[ 0 ] + " - "+ $('select').val() + ui.values[ 1 ] ); } }); $( "#amount" ).val( $('select').val() + $( "#slider-range" ).slider( "values", 0 ) + " - "+ $('select').val() + $( "#slider-range" ).slider( "values", 1 ) ); }); </script> </head> <body> <form action="bul.php" method="post"> <div style="margin-left:20px"> <select name=currency class="f15"> <option value="" selected>TL</option> </select> <label for="amount">Price range:</label> <input type="text" id="amount" name="amount" style="border:0; color:#f6931f; font-weight:bold;" readonly> <br><br> <div id="slider-range" style="width:80%;"></div> <br><br> <input type="submit" value="Show Prices " /> <br><br> </div> </form> </body> </html> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM