rowCount(); is counting less then the number of rows in database

Viewed 42

I'm trying to display a count of all the rows inside a table, Issue is the rowCount() is coming back at 14 when it should be 16, I echoed out my id's to see if it displays all of them and it does. I don't know what else to do here.

 $sql = "SELECT * FROM offers_self WHERE workers = '$userid'";
 $result = $pdo->prepare($sql);
 $result->execute();
 while($row = $result->fetch(PDO::FETCH_ASSOC)) {
   $count = $result->rowCount(); # Here its counting only 14
   echo $row['id']; # Heres where i echo all the ids to check, Comes back to 16
 }

I changed the rowCount() to

$sql = "SELECT COUNT(*) FROM offers_self";
$res = $pdo->query($sql);
$count = $res->fetchColumn();

But its still only counting 14.

0 Answers
Related