Jump to content

Help needed in PHP Tree Structure

- - - - -

  • Please log in to reply
No replies to this topic

#1
liri ayekpam

liri ayekpam

    Newbie

  • Members
  • Pip
  • 8 posts
Hi all,

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
Material

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);


?>




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users