RPeraltaJr
3/5/2018 - 6:41 PM

Get Row Count

<?php 

try {
    foreach($db->query('SELECT * FROM table') as $row) {
        echo '<br>' . $row['first_name'].' '.$row['last_name']; 
    }
} catch(PDOException $ex) {
    echo "An Error occured!"; //user friendly message
}


$stmt = $db->query('SELECT * FROM table');
$row_count = $stmt->rowCount();
echo $row_count.' rows selected';