I have a ajax query with multiple lines and I want the query to show only results that have an "active" status
$query .= "SELECT * FROM students ";
if(isset($_POST["search"]["value"]))
{
$query .= 'first_name LIKE "%'.$_POST["search"]["value"].'%" ';
$query .= 'OR last_name LIKE "%'.$_POST["search"]["value"].'%" ';
The second and third query is for when the user use the search box,
and I want the searchbox to also show only the "active" ones
I tried doing these to no avail
$query .= "SELECT * FROM students WHERE status='active' AND ";
if(isset($_POST["search"]["value"]))
{
$query .= 'first_name LIKE "%'.$_POST["search"]["value"].'%" ';
$query .= 'OR status='active' AND last_name LIKE "%'.$_POST["search"]["value"].'%" ';
$query .= "SELECT * FROM students";
if(isset($_POST["search"]["value"]))
{
$query .= 'first_name LIKE "%'.$_POST["search"]["value"].'% && status='active' ';
$query .= 'OR last_name LIKE "%'.$_POST["search"]["value"].'% && status='active' ';