title: php pdo to display output of mysql query using variable
body: <p>I am new to pdo and battling a little.</p>
  
  <p>I want to populate a table with the results of a mysql query. the query will return a single result based on the the variable </p>
  
  <p>have the following function:</p>
  
  <pre><code> function get_editusers($db){     
      try { 
           $result = $db-&gt;query("SELECT firstname, middlename,surname,fullname,gender, birthdate,homelanguage,department,employeetype,employeestatus,idnumber FROM Persons where employeeid= :empid");  
           return $result;  
      } catch(PDOException $ex) { 
           return $ex; 
      } 
  } 
  
  $useredit= get_editusers($db); 
  </code></pre>
  
  <p>I then use the following to output the values:</p>
  
  <pre><code>while($row = $useredit-&gt;fetch(PDO::FETCH_ASSOC)) 
  {
  echo $row['firstname'];
  echo $row['middelname'];
  echo $row['surname'];
  }
  </code></pre>
  
  <p>This however produces a blank result with no errors.</p>
  
  <p>How can I correct this sytnax? Also I need to change the syntax to bind the variable to vairable $employeeid.</p>
  
  <p>Is this the correct and best method for fetching and outputting the result of a mysql query that outputs a single record? if not please can you advise with a working example.</p>
  
  <p>Thanks in advance,</p>