title: how to list all TABLES(not records) of a database in a drop down list MySQL PHP
body: <p>I am creating an onlineshop, where the user is going to add a new record, by typing the title, description, price and image, but I also want to put a dropdown list of all my TABLES names for the user to select them as a category for adding the product.
  The details of my database are:
  db name = onlineshop</p>
  
  <p>connect.php</p>
  
  <pre><code>&lt;?php    
      // Try to connect to MySQL
      $connect = mysql_connect('localhost','root', '') or die('Sorry could not connect to     database');
      // Check connect and return error if failed
   $use_db = mysql_select_db('onlineshop');
  $create_db = "CREATE DATABASE onlineshop";
  if(!$use_db) {
      echo mysql_error();
      mysql_query($create_db);
      mysql_select_db('onlineshop');
  }
  $con=mysqli_connect('localhost','root', '');
  // Check connection
  if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
  
  // Create database
  $sql="CREATE DATABASE onlineshop";
  if (mysqli_query($con,$sql))
    {
    echo "Database my_db created successfully";
    }
  else
    {
    echo "Error creating database: " . mysqli_error($con);
    }
  
  //main table
  $sql = 'CREATE TABLE mens( '.
         'id INT NOT NULL AUTO_INCREMENT, '.
         'title VARCHAR(20) NOT NULL, '.
         'description  VARCHAR(45) NOT NULL, '.
         'price   FLOAT NOT NULL, '.
         'image varchar(200),'.
         'image_small varchar(200),'.
         'primary key ( id ))';
  
  //copy attributes of the main table
  $sql2= 'CREATE TABLE women AS ( SELECT * FROM mens where 1=2)';
  $sql3= 'CREATE TABLE kids AS ( SELECT * FROM mens where 1=2)';
  $sql4= 'CREATE TABLE infants AS ( SELECT * FROM mens where 1=2)';
  $sql5= 'CREATE TABLE baby_books AS ( SELECT * FROM mens where 1=2)';
  $sql6= 'CREATE TABLE garden AS ( SELECT * FROM mens where 1=2)';
  $sql7= 'CREATE TABLE comics AS ( SELECT * FROM mens where 1=2)';
  $sql8= 'CREATE TABLE cooking AS ( SELECT * FROM mens where 1=2)';
  $sql9= 'CREATE TABLE desktop AS ( SELECT * FROM mens where 1=2)';
  $sql10= 'CREATE TABLE laptop AS ( SELECT * FROM mens where 1=2)';
  $sql11= 'CREATE TABLE mobile AS ( SELECT * FROM mens where 1=2)';
  $sql12= 'CREATE TABLE misc AS ( SELECT * FROM mens where 1=2)';
  $sql13= 'CREATE TABLE moviestv AS ( SELECT * FROM mens where 1=2)';
  $sql14= 'CREATE TABLE music AS ( SELECT * FROM mens where 1=2)';
  $sql15= 'CREATE TABLE games AS ( SELECT * FROM mens where 1=2)';
  
  
  
  $retval = mysql_query( $sql, $connect );
  $retval2 = mysql_query($sql2, $connect);
  $retval3 = mysql_query($sql3, $connect);
  $retval4 = mysql_query($sql4, $connect);
  $retval5 = mysql_query($sql5, $connect);
  $retval6 = mysql_query($sql6, $connect);
  $retval7 = mysql_query($sql7, $connect);
  $retval8 = mysql_query($sql8, $connect);
  $retval9 = mysql_query($sql9, $connect);
  $retval10 = mysql_query($sql10, $connect);
  $retval11 = mysql_query($sql11, $connect);
  $retval12 = mysql_query($sql12, $connect);
  $retval13 = mysql_query($sql13, $connect);
  $retval14 = mysql_query($sql14, $connect);
  $retval15 = mysql_query($sql15, $connect);
  ?&gt;
  </code></pre>
  
  <p>dropdown.php</p>
  
  <pre><code>&lt;?php
  $connect = mysql_connect('localhost','root', '') or die('Sorry could not connect to database');
  
  function runSQL($sql)
  {
      $mysqlConnection = getConnection();
      $ResultSet = $mysqlConnection-&gt;query($sql);
  
      return $ResultSet;
  }
  
  function getTableList()
  {
      $sql = "SHOW TABLES";
      $ResultSet = runSQL($sql);
  
      if(!$ResultSet)
      {
          echo "Table list not found";
      }
  
      return $ResultSet;
  }
  ?&gt;
  </code></pre>
  
  <p>index contains a form as well as a function that i found online that calls the dropdown.php</p>
  
  <p>index.html</p>
  
  <pre><code>   &lt;form action="insert.php" method="post"&gt;
  &lt;br&gt;
  &lt;div&gt;&lt;label for="title"&gt;Title: &lt;/label&gt;&lt;input type="text" name="title"/&gt;&lt;/div&gt;
  &lt;div&gt;&lt;label for="description"&gt;Desc: &lt;/label&gt;&lt;input type="text" name="description"/&gt;&lt;/div&gt;
  &lt;div&gt;&lt;label for="price"&gt;Price: &lt;/label&gt;&lt;input type="text" name="price" /&gt;&lt;/div&gt;
  &lt;input type="submit" name="submit" value="Submit"&gt;
  &lt;/form&gt;
  
  
  
  &lt;form id="imageform" method="post" enctype="multipart/form-data" action='ajaximage.php'&gt;
  Upload your image &lt;input type="file" name="photoimg" id="photoimg" /&gt;
  &lt;/form&gt;
  &lt;div id='preview'&gt;
  &lt;/div&gt; 
  
  
  &lt;?php
  include_once 'dropdown.php';
  ?&gt;
  &lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="POST"&gt;
          &lt;select name="Tables" id="ddTables"&gt;
              &lt;?php
                  $tableResults = getTableList();
                  if($tableResults)
                  {
                      if($tableResults-&gt;rowCount() &gt; 0)
                      {
                          $tables = $tableResults-&gt;fetchAll(PDO::FETCH_NUM);
                          foreach($tables as $table)
                          {
                              $name = $table[0];
                              echo '&lt;option value="'.$name.'"&gt;'.$name.'&lt;/option&gt;';
                          }
                      }
                  }
                  else
                  {
                      echo '&lt;option value="0"&gt;No Data&lt;/option&gt;';
                  }
              ?&gt;
          &lt;/select&gt;
          &lt;input type="submit" id="tableSubmit" value="Submit"/&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>All i get is an empty dropdown list </p>
  
  <p>I really new into PHP, so please let me know of ANY suggestions for my database, as well as if you suggest me to include a script.</p>
  
  <p>i pretty sure that the problem is that the getTablesList() function in the index.html is not returning anything.</p>
  
  <p>open to any suggestions</p>