Hello everyone I'm new to php, mysql, and html and for a project I'm working on have a simple database with id, product, price, and condition. On my html form I have four checkboxes with ranges of prices 0-25, 25-50, 50-75, and 75-100. Here's an example of what I'm trying to do: if the user selects the checkbox with 0-25, it's supposed to echo the id, product, price, and condition of all products that cost 0-25 in a table.I have the checkbox values saved in an array, but I'm completely lost at this point. How can I output values in my database of the checkbox checked.
P.S. I've heard of PDO, but we have to use mysql for this project. Here's my html:
<form action="pricefilter.php" method="post">
<br><b>Filter By Price:</b><br><br>
<input type="checkbox" name="priceFilter[]" id="Price" value="025"/> $0-$25<br><br>
<input type="checkbox" name="priceFilter[]" id="Price" value="2550"/> $25-$50<br><br>
<input type="checkbox" name="priceFilter[]" id="Price" value="5075"/> $50-$75<br><br>
<input type="checkbox" name="priceFilter[]" id="Price" value="75100"/> $75-$100<br><br>
<input type="checkbox" name="priceFilter[]" id="Price" value="100"/> $75-$100<br><br>
<input type="submit" name="submit" value="Submit" />
</form>
Here is my php:
<?php
mysql_connect ("localhost", "root","root") or die (mysql_error());
mysql_select_db ("XUSWAPSAMPLE");
$priceFilter = $_GET['priceFilter'];
$filteredResponse = array ();
foreach($priceFilter as $range)
{
if($range == 025)
{
$query = "select * from Books where Price <= 25";
$sql = mysql_query($query);
array_push($filteredResponse, $sql);
}
if($range == 2550)
{
$query = "select * from Books where Price >= 25 AND Price <=50";
$sql = mysql_query($query);
array_push($filteredResponse, $sql);
}
if($range == 5075)
{
$query = "select * from Books where Price >= 50 AND Price <=75";
$sql = mysql_query($query);
array_push($filteredResponse, $sql);
}
if($range == 75100)
{
$query = "select * from Books where Price >= 75 AND Price <=100";
$sql = mysql_query($query);
array_push($filteredResponse, $sql);
}
if($range == 100)
{
$query = "select * from Books where Price >= 100";
$sql = mysql_query($query);
array_push($filteredResponse, $sql);
}