I need to write some code that cycles through the entire list of tables I have in my database, so first I need to get the list of all tables and add them to an array.
I'm trying to do this using this code:
include('./db.php');
$dataList = array();
$showTable = "SHOW TABLES from databaseA";
$getData = mysqli_query($con, $showTable);
while ($row = mysqli_fetch_row($getData)) {
$dataList[] = $row;
print_r($row);
}
My results are showing as:
Array
(
[0] => Array
(
[0] => Dave
)
[1] => Array
(
[0] => Bob
)
[2] => Array
(
[0] => Chris
)
[3] => Array
(
[0] => Matt
)
}
but if I use echo $dataList[0];
or echo $dataList[1];
I just get the word array
by itself.
I'm not sure what I'm doing wrong here...
I then need to build a php for loop utilizing this, and my initial thought was to do something like this:
for ($i=0; $i <= count($dataList); $i++) {}
but that's not working since I'm defining the array incorrectly....