llamando a una matriz de una función a otra

  • northstjarna
  • Beginner
  • Beginner
  • No Avatar
  • Registrado: Nov 14, 2006
  • Mensajes: 58
  • Loc: Chertsey, UK
  • Status: Offline

Nota Abril 28th, 2010, 12:46 pm

Hola tengo un problema por el que mi cuadro no se transmite de una función a otra...

Este es el código....

Código: [ Select ]
/* get breadcrumb function */
function getbreadcrumb($arraycount,$parentmenuid){
    
    /* get the current level menu */
    global $database_eggbox, $eggbox, $urlmenu_id;
    $query_last_breadcrumb = "select * from menu where menu_id = $parentmenuid order by menu_display_order";
    $last_breadcrumb = mysql_query($query_last_breadcrumb, $eggbox) or die(mysql_error());
    $row_last_breadcrumb = mysql_fetch_assoc($last_breadcrumb);
    $totalRows_last_breadcrumb = mysql_num_rows($last_breadcrumb);
    
    $array_menu[$arraycount][0] = $row_last_breadcrumb['menu_id'];
    $array_menu[$arraycount][1] = $row_last_breadcrumb['page_id'];
    $array_menu[$arraycount][2] = $row_last_breadcrumb['menu_text'];
    $array_menu[$arraycount][3] = $row_last_breadcrumb['menu_parent_menu_id'];
    
    if($array_menu[$arraycount][0] != "") {
        getbreadcrumb($arraycount+1,$array_menu[$arraycount][3]);
    } else {
        
        if($array_menu[$arraycount][2] != "home") {
            /// going to output the first crumb as home
        } else {
            /// else >>
        }
    }
    
    echo $array_menu[$arraycount][2] . " | ";
    
} // end function
  1. /* get breadcrumb function */
  2. function getbreadcrumb($arraycount,$parentmenuid){
  3.     
  4.     /* get the current level menu */
  5.     global $database_eggbox, $eggbox, $urlmenu_id;
  6.     $query_last_breadcrumb = "select * from menu where menu_id = $parentmenuid order by menu_display_order";
  7.     $last_breadcrumb = mysql_query($query_last_breadcrumb, $eggbox) or die(mysql_error());
  8.     $row_last_breadcrumb = mysql_fetch_assoc($last_breadcrumb);
  9.     $totalRows_last_breadcrumb = mysql_num_rows($last_breadcrumb);
  10.     
  11.     $array_menu[$arraycount][0] = $row_last_breadcrumb['menu_id'];
  12.     $array_menu[$arraycount][1] = $row_last_breadcrumb['page_id'];
  13.     $array_menu[$arraycount][2] = $row_last_breadcrumb['menu_text'];
  14.     $array_menu[$arraycount][3] = $row_last_breadcrumb['menu_parent_menu_id'];
  15.     
  16.     if($array_menu[$arraycount][0] != "") {
  17.         getbreadcrumb($arraycount+1,$array_menu[$arraycount][3]);
  18.     } else {
  19.         
  20.         if($array_menu[$arraycount][2] != "home") {
  21.             /// going to output the first crumb as home
  22.         } else {
  23.             /// else >>
  24.         }
  25.     }
  26.     
  27.     echo $array_menu[$arraycount][2] . " | ";
  28.     
  29. } // end function


Ahora, cuando utilice la función mundial para que la matriz no lo tendrá...

Código: [ Select ]
/* get menu functions */
function getmenu($menu_level){
        
    /* get the top most level menu */
    global $database_eggbox, $eggbox, $urlmenu_id, $array_menu;
    $query_top_menu = "select * from menu where menu_parent_menu_id = 0 order by menu_display_order";
    $top_menu = mysql_query($query_top_menu, $eggbox) or die(mysql_error());
    $row_top_menu = mysql_fetch_assoc($top_menu);
    $totalRows_top_menu = mysql_num_rows($top_menu);
    
    if ($menu_level <> 0) {
        echo $array_menu;

......
  1. /* get menu functions */
  2. function getmenu($menu_level){
  3.         
  4.     /* get the top most level menu */
  5.     global $database_eggbox, $eggbox, $urlmenu_id, $array_menu;
  6.     $query_top_menu = "select * from menu where menu_parent_menu_id = 0 order by menu_display_order";
  7.     $top_menu = mysql_query($query_top_menu, $eggbox) or die(mysql_error());
  8.     $row_top_menu = mysql_fetch_assoc($top_menu);
  9.     $totalRows_top_menu = mysql_num_rows($top_menu);
  10.     
  11.     if ($menu_level <> 0) {
  12.         echo $array_menu;
  13. ......


Se trabajó para algunas funciones pero no esta...¿Alguien puede ayudar a explicar lo que estoy haciendo mal?
Gracias
Andi
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Abril 28th, 2010, 12:46 pm

  • northstjarna
  • Beginner
  • Beginner
  • No Avatar
  • Registrado: Nov 14, 2006
  • Mensajes: 58
  • Loc: Chertsey, UK
  • Status: Offline

Nota Abril 28th, 2010, 12:51 pm

Esta bien lo imaginó. Tuve que declarar también la matriz en la función global de la primera función...

Código: [ Select ]
/* /* get breadcrumb function */
function getbreadcrumb($arraycount,$parentmenuid){
    
    /* get the current level menu */
    global $database_eggbox, $eggbox, $urlmenu_id, $array_menu;
  1. /* /* get breadcrumb function */
  2. function getbreadcrumb($arraycount,$parentmenuid){
  3.     
  4.     /* get the current level menu */
  5.     global $database_eggbox, $eggbox, $urlmenu_id, $array_menu;

Publicar Información

  • Total de mensajes en este tema: 2 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 151 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC