gpt4 book ai didi

javascript - 带有 MySQL 的 jQuery 和 PHP 中的价格范围 slider

转载 作者:行者123 更新时间:2023-11-28 23:46:02 26 4
gpt4 key购买 nike

我使用了 jquery 价格范围 slider 。我想使用同一页面上的 jquery 价格范围 slider 过滤掉结果。但是这个 jquery 价格范围 slider 不起作用或该值的变量未发布在同一页面上。 我试过下面的代码,

    <?php 
if(isset($_POST['amount1']))
{
echo $_SESSION['amount1'] = $_POST['amount1'];
}
if(isset($_POST['amount2']))
{
echo $_SESSION['amount2'] = $_POST['amount2'];
}
if(isset($_POST['submit_range']))
{
$sql = mysql_query("select * from hall_search_data_1 where rent BETWEEN '".$_SESSION['amount1']."' AND '".$_SESSION['amount2']."'");
$res = mysql_query($sql)or die(mysql_error());
}
?>
 $(function() {
$( "#slider-range" ).slider({
range: true,
min: 0,
max: 50000,
values: [ 100, 1000 ],
slide: function( event, ui ) {
$( "#amount" ).html( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
$( "#amount1" ).val(ui.values[ 0 ]);
$( "#amount2" ).val(ui.values[ 1 ]);
}
});
$( "#amount" ).html( "$" + $( "#slider-range" ).slider( "values", 0 ) +
" - $" + $( "#slider-range" ).slider( "values", 1 ) );
});
<div class="slider"> 
<div id="slider-range"></div>

<form method="get">
<input type="hidden" id="amount1">
<input type="hidden" id="amount2">
<input type="submit" name="submit_range" value="Submit">
</form>
</div>

<!--here php code ---->

if(isset($_POST['amount1']))
{
echo $_SESSION['amount1'] = $_POST['amount1'];
}

if(isset($_POST['amount2']))
{
echo $_SESSION['amount2'] = $_POST['amount2'];
}

if(isset($_POST['submit_range']))
{


$sql = mysql_query("select * from hall_search_data_1 where rent BETWEEN '".$_SESSION['amount1']."' AND '".$_SESSION['amount2']."'");
$res = mysql_query($sql)or die(mysql_error());
}

所以请帮助我。

最佳答案

<div class="slider"> 
<div id="slider-range"></div>

<form method="get">
<input type="hidden" id="amount1">
<input type="hidden" id="amount2">
<input type="submit" name="submit_range" value="Submit">
</form>
</div>

在你的表单中你错过了 name 属性,因此你得到了

Undefined index: amount1,amount2

以上错误。

如下更新代码

<form method="get">
<input type="hidden" id="amount1" name="amount1">
<input type="hidden" id="amount2" name="amount2">
<input type="submit" name="submit_range" value="Submit">
</form>

关于javascript - 带有 MySQL 的 jQuery 和 PHP 中的价格范围 slider ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33543772/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com