title: mysql_result in PDO
body: <p>Below is the code I have, it was all written in mysql. I am trying to switch to PDO. My question is, what is the equivalent of mysql_result in PDO?</p>
  
  <pre><code>$query = "SELECT id, firstname, lastname FROM table";
  if($mysql_query = mysql_query($query)){
      $id = mysql_result($mysql_query, 0, 'id');
      $firstname = mysql_result($mysql_query, 0, 'firstname');
      $lastname = mysql_result($mysql_query, 0, 'lastname');
  }
  </code></pre>
  
  <p>So far, I am only able to execute the $query by doing the following below.</p>
  
  <pre><code>$query = $PDO -&gt; prepare("SELECT id, firstname, lastname FROM table");
  $query -&gt; execute();
  </code></pre>