Monday, September 14, 2015

SHOW TABLES in mySql

<?php
$db=mysql_connect('localhost','mpb','123456') or die('Error');
mysql_select_db('mpb') or die('error db');

$sql = "SHOW TABLES FROM mpb_asd";
 $result = mysql_query($sql);
 $arrayCount = 0;
 while ($row = mysql_fetch_row($result)) {
  $tableNames[$arrayCount] = $row[0];
  $arrayCount++; //only do this to make sure it starts at index 0
 }
 echo "<pre>";
 print_r($tableNames);
  echo "</pre>";
?>

No comments:

Post a Comment