Reputation: 7588
I have multiple tables named like so MOM2016, MOM2017, MOM2018.
When i run query in phpmyadmin
SHOW TABLES LIKE 'MOM%'
it returns 3 items as expected.
BUT!!!! When i run in php, my code seem to give me only 1 item in the array (first one only MOM2016).
$sql = "SHOW TABLES LIKE 'MOM%'";
$result = $conn->query($sql);
$dbArray = $result->fetch_assoc();
echo "DEBUG:".count($dbArray);
This give:
DEBUG:1
My php code is wrong? Pls help.
Upvotes: 0
Views: 87
Reputation: 147286
If you want to get all the results at once,
$dbArray = $result->fetch_all();
echo "DEBUG:".count($dbArray);
Upvotes: 1
Reputation: 1403
Iterate through your fetch resource
$dbArray = array();
while ($row = $result->fetch_assoc()) {
$dbArray[] = $row;
}
print "DEBUG: " . count($dbArray);
Upvotes: 1