title: Using PDO with MySQL to $_GET two columns
body: <p>I'm working on a Pastebin-esque project in my free time, and last night I solved an issue I've had for a couple of days. (see <a href="https://stackoverflow.com/questions/40099530/pdo-get-and-selecting-from-mysql-database">this</a> thread) However, I managed to mess it all up when I tried to make the code fetch a second column, 'Title'.</p>
  
  <p><strong>Please read the hyperlinked thread and look at Odin's answer or see the code below.</strong></p>
  
  <p>How can I make that code fetch multiple columns?</p>
  
  <p>The code:
  viewpaste.php:</p>
  
  <pre><code>    require 'connection.php';
  $getid = $_GET["id"];
  $result=retrieve("SELECT paste FROM pasteinfo WHERE id=?",array($getid));
  $row=$result-&gt;fetch();
  //To get paste column of that id
  $paste=$row-&gt;paste;
  echo $paste;
  </code></pre>
  
  <p>connection.php:</p>
  
  <pre><code>try{
  $db = new PDO('mysql:host=localhost;dbname=database_name;charset=utf8mb4', 'database_username', 'database_password');
  $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  $db-&gt;setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
  }
  catch (PDOException $ex){
  echo $ex-&gt;getMessage();return false;
  }
  
  function retrieve($query,$input) {
   global $db;
   $stmt = $db-&gt;prepare($query);
   $stmt-&gt;execute($input);
   $stmt-&gt;setFetchMode(PDO::FETCH_OBJ);   
   return $stmt;
  }
  </code></pre>
  
  <p>Just in case you need a little bit more of an explanation of my project, I'm making a pastebin clone (from scratch) and am trying to make a page where a user can enter the id of whatever paste they're wanting to view in the URL and have my code grab all the title and paste data of that id. This should all be done with $_GET, and I had it solved until I realized I never got titles working, and here we are.</p>
  
  <p>Thanks!</p>