I am trying to add new arrays to an existing array dynamically from a database but my loop is only adding the last row from mysql_fetch_row. I think it is actually overwriting the same array.
PHP Code
<?php
$con = require_once('./dbconnect.php');
global $con;
mysql_select_db("packages", $con);
$packages = mysql_query("SHOW TABLES FROM packages");
while($row = mysql_fetch_row($packages)){
$node = array();
foreach($row as $key2 => $value2){
$node[$row[0]] = array("Item1" => "Other dynamic Info here");
}
}
print_r($node);
mysql_close($con);
?>
The output is as follows:
Array
(
[Pack1] => Array
(
[Item1] => Other dynamic Info here
)
)
It should be outputting:
Array
(
[Pack1] => Array
(
[Item1] => Other dynamic Info here
)
)
Array
(
[Pack2] => Array
(
[Item2] => Other dynamic Info here
)
)
I have been trying to get this foreach() loop to work for about a day now...what am i doing wrong?