Hello everyone.
Can someone tell me what’s wrong in my script, my query returns nothing, I’m having a hard time debugging.
I’ll post the snippet of the code where I think the code is wrong.
[code=php]
if($search == “Master”)
{
if($cat1 == 1){
if($cat2 == 0){
$age .= ‘AND age <= 20’;
}
if($cat2 == 1){
$age .= ‘AND age >= 21 AND age <= 30’;
}
if($cat2 == 2){
$age .= ‘AND age >= 31 AND age <= 40’;
}
if($cat2 == 3){
$age .= ‘AND age >= 41 AND age <= 50’;
}
if($cat2 == 4){
$age .= ‘AND age >= 51 AND age <= 60’;
}
}
if($cat1 == “”){
$age .= ‘AND age <= 60’;
}
if($cat3 == 1){
if($cat4 == 0){
$exp .= ‘AND years_exp == 1’;
}
if($cat4 == 1){
$exp .= ‘AND years_exp == 2’;
}
if($cat4 == 2){
$exp .= ‘AND years_exp == 3’;
}
if($cat4 == 3){
$exp .= ‘AND years_exp == 4’;
}
if($cat4 == 4){
$exp .= ‘AND years_exp >= 5’;
}
}
else
{
$exp .= ‘AND years_exp >= 1’;
}
}
$result = mysql_query(“SELECT * FROM users WHERE position_applied
LIKE ‘%$search%'” . $age . $exp);
$cat1, $cat2, $cat3, $cat4 values came from a form, I try to echo each variables and as I expected it has a value. Say my value are this:
$search = Master; $cat1 = 1; $cat2 = 2; $cat3 = 1; $cat4 = 2;
Which means my $age will be equal to ‘AND age >= 31 AND age <= 40’ and $exp will be ‘AND years_exp == 3’, and that will be the one inserted in the query. However it seems that the query can’t contain it. ?