I am having problem getting my query to exclude my “soft delete” column I have attached my code below any tips on getting this to work? it shows rows that have the deleted = 1 and i need it just to show 0
$query=mysql_real_escape_string($_GET['query']);
$query_for_result=mysql_query("SELECT * FROM Assets WHERE
`Badge` like '%".$query."%' or
`Status` like '%".$query."%' or
`First Name` like '%".$query."%' or
`Last Name` like '%".$query."%' or
`Service Tag` like '%".$query."%' or
`Asset Tag` like '%".$query."%' and
`deleted` = '0' ")or die(mysql_error());
if(mysql_num_rows($query_for_result1)==0){
}
while($data_fetch=mysql_fetch_array($query_for_result))
{
echo '<h3>';
echo "<a href=\"modify.php?id=" . $data_fetch['id'] . "\">" . $data_fetch['First Name'] . ' ' . $data_fetch['Last Name'] . "</a>";
echo '<br/><b>Badge:</b> '. $data_fetch['Badge'];
echo '<br/> <b>Service Tag:</b> '. $data_fetch['Service Tag'];
echo ' <b>Asset Tag:</b> '. $data_fetch['Asset Tag'];
echo '<br/> <b>Status:</b> '. $data_fetch['Status'];
echo '<br/><b>Employee Status: </b>';
if( $data_fetch['Employee Status'] == 'Active' ){
echo '<font color="#32CD32">' . $data_fetch['Employee Status'] . '</font>';
}
elseif( $data_fetch['Employee Status'] == 'Terminated' ){
echo '<font color="red">' . $data_fetch['Employee Status'] . '</font>';}
echo '<br/> <b>Last Modified:</b> '. $data_fetch['Last Modified'];
echo "<span> </span>";
echo '</h3>';
echo '<br/><p>' ;
}
All of the conditionals are in the same scope. What this means is, as soon as you hit the first condition that is true, the entire where clause is true. You need to put the OR clauses in parenthesis.