title: Need to get last 4 lines from a table, yet not getting any results
body: <p>I am quite new to PHP and I am trying to get the last 4 rows from a product table.... I am however not getting any type of results:( </p>
  
  <p>I am not too sure what I am doing wrong, I tried to use a for loop to change the <code>prod_id</code> each time in the named parameter but it somehow doesn't bring up any results can anyone advise what I am doing wrong?</p>
  
  <pre><code>$db = new PDO($dsn, $username, $password);
  
  for ($prod_id = 4; $prod_id&lt;=8 ; $prod_id++)
  {   
      $query2 = "SELECT p_type, p_name FROM `products` WHERE prod_id = :prod_id ";
      $prod = $db-&gt;prepare($query2);
      $prod-&gt;bindValue(':prod', $prod);
      $prod-&gt;execute();
      $detail=$prod-&gt;fetch();
  }
  foreach($prod as $result)
  {
      echo $result['p_type'] . ' ';
      echo $result['p_name'] . ' &lt;br /&gt;';
  }
  </code></pre>