Jump to content

php code not connecting with price range slider


Hannah123456

Recommended Posts

I have created this code but the php is not connecting up with the jquery price slider, can anyone help and suggest what may be wrong?
 
<?php
 
require_once 'config.php';
include 'header.php';
include('db.php');
include('database.php');
 
 
if($_POST['amount']){
$values = $_POST['amount'];
 
$values = str_replace(array(' ', '£'), '', $_POST['amount']);
list($min, $max) = explode(' ', $values);
$sql = "SELECT `recipe_name`, `recipe_price`,  `Image` 
        FROM `recipe` 
        WHERE `recipe_price` BETWEEN :min AND :max";
$stmt = $DB->prepare($sql);
$stmt->execute(array(':min' => $min, ':max' => $max));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (count($rows) > 0) {
    foreach ($rows as $row) {
        // do loop stuff
    }
} else {
    $min = 0;
    $max = 10;
    $HTML = '';
}
}
 
?>

 

 

<script>
  $(function() {
    $( "#slider-range" ).slider({
      range: true,
      min: 0,
      max: 10,
      values: [ 0, 10 ],
      slide: function( event, ui ) {
        $( "#amount" ).val( "£" + ui.values[ 0 ] + " - £" + ui.values[ 1 ] );
      }
    });
    $( "#amount" ).val( "£" + $( "#slider-range" ).slider( "values", 0 ) +
      " - £" + $( "#slider-range" ).slider( "values", 1 ) );
  });
  </script>
 
 
 
<form action="" method="post" id="amount">
<div style="margin-left:20px">
    <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:50%;"></div>
    <br><br>
    <input type="submit" value="Find" />
    <br><br>
    <?php echo $HTML?>
</div>
</form>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.