Question: i want to check the rows if there are any events that are binded to a host with host\_id parameter, everything is well if there is not any events binded to a host, its printing out none, but if host is binded to one of the events, its not listing the events, but if i remove the codes that i pointed below with commenting problem starts here and problem ends here, it lists the events. I'm using the fetchAll function above too for another thing, there is not any such that error above there, but with the below part, it's not listing the events, how can i fix that? 

Thanks

```
try
{
    $eq = "SELECT * FROM `events` WHERE `host_id` = :id AND `confirmed` = '1' ";
    $eq_check = $db->prepare($eq);
    $eq_check->bindParam(':id', $id, PDO::PARAM_INT);
    $eq_check->execute();

    //problem starts here
    $count3 = $eq_check->fetchAll();
    $rowCount = count($count3);

    if ($rowCount == 0) 
    {
        echo "None"; 
    }
    //problem ends here

    while($fetch = $eq_check->fetch (PDO::FETCH_ASSOC) )
    { 
        $_loader = true;

        $event_id = $fetch['event_id'];
        $event_name = $fetch['event_name'];
        $link = "https://www.mywebsite.com/e/$event_id";

        echo "<a target=\"_blank\" href=\"$link\"><li>$event_name</li></a>";
    }
} 
catch(PDOException $e)
{
    $log->logError($e." - ".basename(__FILE__));
}

```

Thank you

Answer: 
You can't fetch twice without executing twice as well. If you want to not just re-use your `$count3` item, you can trigger `closeCursor()` followed by `execute()` again to fetch the set again.

To reuse your `$count3` variable, change your `while` loop into: `foreach($count3 as $fetch) {`
The reason that it is not listing the events when you have your code is that the result set is already fetched using your fetchAll statement (The `fetchAll` doesn't leave anything to be fetched later with the `fetch`).

In this case, you might be better off running a `select count(*)` to get the number of rows, and then actually running your full query to loop through the results:

An example of this in PDO is [here](http://php.net/manual/en/pdostatement.rowcount.php):

```
<?php
$sql = "SELECT COUNT(*) FROM fruit WHERE calories > 100";
if ($res = $conn->query($sql)) {

    /* Check the number of rows that match the SELECT statement */
  if ($res->fetchColumn() > 0) {

        /* Issue the real SELECT statement and work with the results */
         $sql = "SELECT name FROM fruit WHERE calories > 100";
       foreach ($conn->query($sql) as $row) {
           print "Name: " .  $row['NAME'] . "\n";
         }
    }
    /* No rows matched -- do something else */
  else {
      print "No rows matched the query.";
    }
}

$res = null;
$conn = null;
?>

```

Note that you cannot directly use rowCount to get a count of rows selected - it is meant to show the number of rows deleted and the like instead.