The following code is supposed to count the number of tables in the database. It only counts the latest table. As does my attempt to list the tables by name, only listing the latest. All the tables are just for testing and do not have any different attributes.
function checkdbempty(){
global $fsdbh;
$results = $fsdbh->query("show tables");
foreach($results as $result); { $int += 1; }
return $int;
}
That will return 1 result.
function checkdbempty(){
global $fsdbh;
$check = $fsdbh->query('show tables')->fetch(PDO::FETCH_ASSOC);
foreach($check as $ch){ echo $ch; }
}
This will tell me the name of the first table:
function checkdbempty(){
global $fsdbh;
$check = $fsdbh->query('show tables')->fetch(PDO::FETCH_ASSOC); $result = '';
foreach($check as $ch){ $result.= $ch; }
return $result;
}
And it will count only one with ->fetch(PDO::FETCH_NUM);
What is the problem
Try this: