I Have an array of Databases and Tables from MySQL. I Can't Seem to Get a List of Tables under each database in Smarty? I Have tried multiple foreach statements and none seem to work. The Database Name shows correct but the tables do not. I appreciate all of the help.
My PHP:
$conn = connect();
$db_sql = $conn->query("SHOW DATABASES;");
$dbs = array();
while ($db = $db_sql->fetch_array(MYSQLI_NUM))
{
$db_name = $db[0];
$dbs[] = $db_name;
}
$tables = array();
foreach ($dbs as $db => $value) {
$table_sql = $conn->query("SHOW TABLES FROM $value");
while ($table_ = $table_sql->fetch_array(MYSQLI_NUM))
{
$tb_name = $table_[0];
$tables[$value]['Tables'][] = $tb_name;
}
}
$smarty->assign("dbs", $tables);
My Smarty:
{foreach from=$dbs key=db item=value}
<li>
<a class="tree-toggler nav-header" href="#" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-th-list"></span> {$db}</a>
<ul class="nav nav-list tree">
{foreach from=$value->Tables item=$table}
<li><a href="#">{$table}</a></li>
{/foreach}
</ul>
</li>
{/foreach}