title: Check if table exist using PDO
body: <p>Hello all decided to begin learning PDO. However i'm having trouble creating a function to check if a table exists in my db.</p>
  
  <p>Each individual item has there own table in which the table name is ($id).</p>
  
  <pre><code>&lt;?php
  include_once('config.php');
  include_once('simple_html_dom.php');
  
  $html = file_get_html('http://localhost:8888/CDOnline%20Online.html');
  
  foreach($html-&gt;find('div.product-stamp-inner') as $content) {   
  
  $detail['itemid'] = $content-&gt;find('a',0)-&gt;href;
  $detail['itemid'] = substr($detail['itemid'], 40, 6);
  if (strpos($detail['itemid'], "?") !== false) {
  $detail['itemid'] = substr($detail['itemid'], 0, 5);
  }
  $id = $detail['itemid'];
  
  tableExists($dbh, $id);
  }
  
  function tableExists($dbh, $id)
  {
  //check if table exists
  }
  
  $dbh = null;
  ?&gt;
  </code></pre>
  
  <p>I've tried to scour the forums in search of an answer but came up empty handed. The only thing that got me close to my answer was:</p>
  
  <pre><code>function tableExists($dbh, $id)
  {
  $results = $dbh-&gt;query("SHOW TABLE LIKE `$id`");
  if(count($results)&gt;0){echo 'table exists';}
  }
  </code></pre>
  
  <p>But that just says all tables exists, when half of the tables don't exist. </p>
  
  <p>Edit:The table should exist if there is 1 or more rows.</p>