PHP nested if

I wasn’t able to combine to two scenarios so I decided to nest it. The problem is that the else condition doesn’t print. Any Ideas on how I can achieve this?

<?php
if($sMan == true || $gWoman == true || $gMan == true || $biMan == true || $biWoman == true || $sWoman == true) {

if($matchAge >= $idealAge_1 && $matchAge <= $idealAge_2) {
    print "You have a match";

};

} else {
    
    print "no match";
    
    ?>
    <script type="text/javascript"> 
    $(function () {
        
    $('.approved:contains(no match)').addClass('no-match');
    
    });
    
    </script>

<?php
    
}



?>

Remove semi-colon.

What is your first if for? All it seems to do is confirm it’s a person.

Well judging that you have No Match inside the else tells me that the else belongs to the inside if condition, correct?

<?php
if($sMan == true || $gWoman == true || $gMan == true || $biMan == true || $biWoman == true || $sWoman == true) {

    if($matchAge >= $idealAge_1 && $matchAge <= $idealAge_2) {
        print "You have a match";
    
    }else{
        
        print "no match";
    
?>
    <script type="text/javascript"> 
    $(function () {
        
    $('.approved:contains(no match)').addClass('no-match');
    
    });
    
    </script>

<?php    
    }
}
?>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.