I am trying to generate a tree structure. It is working as I like, in local server, but it is not working in the live server. The following is the code, please help. Thanks in advance.
OUTPUT IN LOCAL
Production Equipment
OUTPUT IN SERVER
Production Equipment
The output is not going beyond Hardware1 in the live server.
<?php
$query = mysql_query("SELECT * FROM pm1materialcategories ");
while ( $row = mysql_fetch_assoc($query) )
{
$menu_array[$row['matcatId']] = array('name' => $row['mat_categories'],'parent' => $row['matparentid']);
}
function generate_menu($parent)
{
global $menu_array;
foreach($menu_array as $key => $value)
{
if ($value['parent'] == $parent)
{
echo '<li><a href="/category/' . $value['name'] . '/">' . $value['name'] . '</a></li><ul id='.$j.' style="display:none">';
generate_menu($key);
echo '</ul>';
}
}
}
generate_menu(0);
?>


Sign In
Create Account

Back to top









