This is my PHP code
// category filter
if(!isset($_POST['products']) || $_POST['products'] == ""){
$category_filter = "";
} else {
$category_filter = " AND cat_id='".$_POST['products']."'";
}
// offers filter
if($_POST['offer'] != "YES")
{
$offer_filter = "";
} else {
$offer_filter = " AND offer=1";
}
$sql = $db->get_rows("
SELECT *, ( 3959 * ACOS( COS( RADIANS(".$_POST['lat'].") ) * COS( RADIANS( latitude ) ) * COS( RADIANS( longitude ) - RADIANS(".$_POST['lng'].") ) + SIN( RADIANS(".$_POST['lat'].") ) * SIN( RADIANS( latitude ) ) ) ) AS distance
FROM stores
WHERE status=1 AND approved=1 ".$offer_filter." ".$category_filter."
HAVING distance <= ".$_POST['distance']."
ORDER BY distance ASC
LIMIT 0,60");
I am looking to get the correct value for $offer_filter
in my SQL query above as is perfectly happening for $category_filter
.
I think I am missing out something somewhere... please if someone can help me with this...
The following is my HTML Code in the php index file for the checkbox input...
<input type="checkbox" name="offer" value="Yes" onChange="cachesearch = '';$('#clinic-finder-form').submit();"> Discount Offers Available