title: PDO MySQL Query only returning one set of results
body: <p>I built a search form for an app and it is currently only pulling back on result at a time where there should be multiples. I am sure this is something dumb and was wondering if someone can tell me what I am doing wrong.</p>
  
  <p>Here is the full code:</p>
  
  <pre><code>&lt;?php
  
  // php search data in mysql database using PDO
  // set data in input text
  
  $TaskId = "";
  $ClientId="";
  $TaskName = "";
  $TaskDescription = "";
  $TaskStartAt = "";
  
  
  if(isset($_POST['Find']))
  {
      // connect to mysql
  try {
      $pdoConnect = new PDO("mysql:host=localhost;dbname=tt","root","root");
  } catch (PDOException $exc) {
      echo $exc-&gt;getMessage();
      exit();
  }
  
  // id to search
  //$TaskId = $_POST['TaskId'];
  $ClientId = $_POST['ClientId'];
  // date to search
  //$DateCreated = $_POST['DateCreated'];
  
   // mysql search query
  $pdoQuery = "SELECT * 
  FROM tasks t 
  left join users u using (UserId)
  left join clients cl using (ClientId)
  WHERE t.isdeleted = 0 and  ClientId = :ClientId";
  
  $pdoResult = $pdoConnect-&gt;prepare($pdoQuery);
  
  //set your id to the query id
  
  $pdoExec = $pdoResult-&gt;execute(array(":ClientId"=&gt;$ClientId));
  
  
  if($pdoExec)
  {
          // if id exist 
          // show data in inputs
      if($pdoResult-&gt;rowCount()&gt;0)
      {
          echo '&lt;table&gt;';
          foreach   
          ($pdoResult as $rows)
          {
              //$TaskId = $row['TaskId'];
              $ClientId = $rows['ClientId'];
             // $TaskName = $row['TaskName'];
             // $TaskDescription = $row['TaskDescription'];
          }
          echo '&lt;/table&gt;';
      }
          // if the id not exist
          // show a message and clear inputs
  
     }else{
      echo 'ERROR Data Not Inserted';
    }
  }
  
  
  ?&gt;
  
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Task Tracker&lt;/title&gt;
      &lt;link rel="stylesheet" href="css/table.css" type="text/css" /&gt;
  
  &lt;link rel="stylesheet" href="assets/demo.css"&gt;
  &lt;link rel="stylesheet" href="assets/header-fixed.css"&gt;
  &lt;link href='http://fonts.googleapis.com/css?family=Cookie' rel='stylesheet'    type='text/css'&gt;
  &lt;script type="text/javascript"&gt; 
  //Display the Month Date and Time on login.
  function display_c(){
   var refresh=1000; // Refresh rate in milli seconds
  mytime=setTimeout('display_ct()',refresh)
  }
  
  function display_ct() {
  var strcount
  var x = new Date()
  document.getElementById('ct').innerHTML = x;
  tt=display_c();
  }
  &lt;/script&gt;
  
   &lt;/head&gt;
  &lt;body&gt;
  
  &lt;header class="header-fixed"&gt;
  &lt;div class="header-limiter"&gt;
  
      &lt;h1&gt;&lt;a href="#"&gt;Task Tracker&lt;/a&gt;&lt;/h1&gt;
  
  
  
  
      &lt;nav&gt;
          &lt;a href="dashboard.php" class =&gt;Dashboard&lt;/a&gt;
          &lt;a href="addtask.php" class=&gt;Task Management&lt;/a&gt;
    &lt;a href="configuration.php" class =&gt;Configuration&lt;/a&gt;
    &lt;a href="logout.php" class =&gt;Logout&lt;/a&gt;
    &lt;a href="search.php" class ="selected"&gt;Reports &amp; Analytics&lt;/a&gt;
  
      &lt;/nav&gt;
      &lt;/nav&gt;
  
     &lt;/div&gt;
    &lt;/header&gt;
  
      &lt;title&gt; Query a task&lt;/title&gt;
  
      &lt;meta charset="UTF-8"&gt;
  
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
  
     &lt;/head&gt;
  
      &lt;form action="search.php" method="post"&gt;
  
         &lt;!--  Enter a Task Id : &lt;input type="text" name="TaskId" value=""&gt; &lt;br&gt;&lt;br&gt; --&gt;
          Enter a Client Id : &lt;input type="text" name="ClientId" value="&lt;?php echo $ClientId;?&gt;"&gt;&lt;br&gt;&lt;br&gt;
  
  
  
          &lt;input type="submit" name="Find" value="Find Data"&gt;
  
          &lt;br&gt; &lt;/br&gt;
  
  
          &lt;table border="0"&gt;
          &lt;tr COLSPAN=2 BGCOLOR="lightblue"&gt;
          &lt;td&gt;Id&lt;/td&gt;
          &lt;td&gt;Client&lt;/td&gt;
          &lt;td&gt;Task Name&lt;/td&gt;
          &lt;td&gt;Task Description&lt;/td&gt;
          &lt;td&gt;Hours&lt;/td&gt;
          &lt;td&gt;Date Created&lt;/td&gt;
          &lt;td&gt;Who Completed Task&lt;/td&gt;
     &lt;/tr&gt;
      &lt;?php     
      {
  
     if($pdoResult-&gt;rowCount()&gt;0) 
  
      {
    echo "&lt;tr&gt;".
         "&lt;td&gt;".$rows["TaskId"]."&lt;/td&gt;".
         "&lt;td&gt;".$rows["ClientName"]."&lt;/td&gt;".
         "&lt;td&gt;".$rows["TaskName"]."&lt;/td&gt;".
         "&lt;td&gt;".$rows["TaskDescription"]."&lt;/td&gt;".
         "&lt;td&gt;".$rows["Hours"]."&lt;/td&gt;".
         "&lt;td&gt;".$rows["DateCreated"]."&lt;/td&gt;".
         "&lt;td&gt;".$rows["UserName"]."&lt;/td&gt;".
         "&lt;/tr&gt;";
      }
  
     else{
          echo 'No data associated with this Id';
      }
  
   }
  ?&gt;
  
  &lt;/table&gt;
      &lt;/form&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>