howard-moore Posted February 22, 2013 Share Posted February 22, 2013 Apologies to all if I am being completely thick which works fine when running on a page on its own, but when I try to repeat the script further down the page, it doesn't show at all. Basically, it appears only to show once on a page, and I cannot make it appear more than once. Can anyone help me with this? <? $result=mysql_query("SELECT id, title, link, parent_code, page_order, menu_title, parent_title, page_type, live, editable, installed FROM PCNET_$filename WHERE type='PAGE' AND installed='checked' AND page_order!='x' ORDER BY parent_code, ABS(page_order), title"); $menu = array( 'items' => array(), 'parents' => array() ); while ($items = mysql_fetch_assoc($result)) { $menu['items'][$items['id']] = $items; $menu['parents'][$items['parent_code']][] = $items['id']; } function buildMenu($parent_code, $menu) { $html = ""; if (isset($menu['parents'][$parent_code])) { $html .= "\n"; foreach ($menu['parents'][$parent_code] as $itemId) { if(!isset($menu['parents'][$itemId])) { $html .= "<tr><td class=\"".$menu['items'][$itemId]['page_type']."_EDIT\"><ul class=\"edit clear\"><li><a href=\"admin_pages_".$menu['items'][$itemId]['page_type'].".php?eid=".$menu['items'][$itemId]['id']."\">Edit / Delete<span></span></a></li></ul></td> <td class=\"".$menu['items'][$itemId]['page_type']."_b_c\">".$menu['items'][$itemId]['page_order']."</td> <td class=\"".$menu['items'][$itemId]['page_type']."_b_l\">".$menu['items'][$itemId]['menu_title']."</td> <td class=\"".$menu['items'][$itemId]['page_type']."_b_l\">".$menu['items'][$itemId]['parent_title']."</td> <td class=\"".$menu['items'][$itemId]['page_type']."_b_c\"><img src=\"../data/admin_docs_".$menu['items'][$itemId]['live'].".gif\" title=\"Showing Page\"></td></tr>"; } $html .= "</tr> \n"; if(isset($menu['parents'][$itemId])) { $html .= "<tr><td class=\"".$menu['items'][$itemId]['page_type']."_EDIT\"><ul class=\"edit clear\"><li><a href=\"admin_pages_".$menu['items'][$itemId]['page_type'].".php?eid=".$menu['items'][$itemId]['id']."\">Edit / Delete<span></span></a></li></ul></td> <td class=\"".$menu['items'][$itemId]['page_type']."_b_c\">".$menu['items'][$itemId]['page_order']."</td> <td class=\"".$menu['items'][$itemId]['page_type']."_b_l\">".$menu['items'][$itemId]['menu_title']."</td> <td class=\"".$menu['items'][$itemId]['page_type']."_b_l\">".$menu['items'][$itemId]['parent_title']."</td> <td class=\"".$menu['items'][$itemId]['page_type']."_b_c\"><img src=\"../data/admin_docs_".$menu['items'][$itemId]['live'].".gif\" title=\"Showing Page\"></td></tr>"; $html .= buildMenu($itemId, $menu); } } $html .= "\n"; } return $html; } echo buildMenu(0, $menu); ?> Thanks - Neil Link to comment https://forums.phpfreaks.com/topic/274839-two-php-scripts-on-the-same-page/ Share on other sites More sharing options...
howard-moore Posted February 22, 2013 Author Share Posted February 22, 2013 Sorry - missed some typing in the above post. Basically I am trying to repeat the above code twice on the same web-page, and it is only allowing me to show it the once. Any ideas? Link to comment https://forums.phpfreaks.com/topic/274839-two-php-scripts-on-the-same-page/#findComment-1414304 Share on other sites More sharing options...
Jessica Posted February 22, 2013 Share Posted February 22, 2013 You cannot define a function twice in the same script. Post exactly what you tried, turn on error reporting, and post the output. Link to comment https://forums.phpfreaks.com/topic/274839-two-php-scripts-on-the-same-page/#findComment-1414306 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.