I have built an ajax page that gets data by checking which value is selected from the dropdown box. While the code below works perfectly for all possible selections it requires more code for more choices. Is there a better practice available to use more efficient code

I have built an ajax page that gets data by checking which value is selected from the dropdown box. While the code below works perfectly for all possible selections it requires more code for more choices. Is there a better practice available to use more efficient code

PHP Code:
$sql="SELECT m.id memberId, m.firstName firstName, m.surName surName, m.grade grade, m.dueDate dueDate, m.dob dob, m.email email, m.phone phone, c.name clubName FROM members AS m
      LEFT JOIN clubs AS c ON m.club = c.id"
;
if(isset(
$_GET)){
  
// get data
  
$g=$_GET["g"];
  
$u=$_GET["u"];
  
$d=$_GET["d"];

  
// Check is grade is set 
  
if($g == 0){
    
// if g is not set
    // check if u is set
    
if($u != "0"){
      
$sql .= " WHERE c.name = '$u'";
      if(
$d == 1){
        
$today date('Y-m-d');
        
$sql .= " AND dueDate < '$today'";
      }
    }else{
      if(
$d == 1){
        
$today date('Y-m-d');
        
$sql .= " WHERE dueDate < '$today'";
      }
    }
  }else{
    
// if g is set
    
$sql.= " WHERE grade = '".$g."'";
    if(
$d == 1){
        
$today date('Y-m-d');
        
$sql .= " AND dueDate < '$today'";
      }
    
// check is u is set
    
if($u != "0"){
      
$sql .= " AND c.name = '$u'";
      if(
$d == 1){
        
$today date('Y-m-d');
        
$sql .= " AND dueDate < '$today'";
      }
    }
  }