Jump to content

Two PHP scripts on the same page?


howard-moore

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.