Select dropdown filter month & year date code, not pulling any data?

Code is not pulling any data? I’m still learning pdo.

<?php
//filter_month.php
    {
        include 'db_connection2.php';
        
        $query = " SELECT 
  g.name as `group`,
  COUNT(ar.present) as attended

 FROM 
   attendance_record ar
   
   INNER JOIN
   _person p
   ON ar.personid = p.id
   
   INNER JOIN
   _person_group g 
   ON ar.groupid = g.id
   
   
-- WHERE
AND
YEAR(date) = ?
AND
Month(date) = ?
AND
ar.present = 1

GROUP BY g.name
ORDER BY ar.date, g.name ASC
                 ";
                 
$stmt = $pdo->prepare($query);
 
$stmt->bindParam(':month', $_POST['month'], PDO::PARAM_STR);
$stmt->bindParam(':year', $_POST['year'], PDO::PARAM_STR);
$stmt->execute();       

 $result = $query;


     //-----------------------------Table------------------------------------//    

        $output .= '  
           <table class="table table-bordered"> 
           
    <div align="center"><font size=4>
    Total present (by Class)</font>
    </div>

                   <tr>  
                               <th style="text-align:center;" width=".001%"><font size=2><span>Class</span></th>
                              <th style="text-align:center;" width=".001%"><font size=2><span>Attended</span></th>
                </tr>  
                
                     ';
                     
                  foreach($stmt as $row)
       
            {       
  
 $output .= '  
                     <tr>  
                 <td style="text-align:center;">' . $row['group'] . '</td>
                 <td style="text-align:center;">' . $row['attended'] . '</td>
                     </tr>  
       ';
            }
      
        $output .= '</table>';    }
        
   $pdo=null;
    // By this way you can close connection in PDO.    
 ?>

A post was merged into an existing topic: Pull records by Year dropdown list

Sponsor our Newsletter | Privacy Policy | Terms of Service