function in php for displaying a menu

Posted by Stanislas Piotrowski on Stack Overflow See other posts from Stack Overflow or by Stanislas Piotrowski
Published on 2012-11-19T16:50:33Z Indexed on 2012/11/19 17:00 UTC
Read the original article Hit count: 303

Filed under:
|
|
|
|

I met some trouble with a function I have written.

In fact I have an array in which I have different custom values.

I would like to display the result of that, so here is my function

function getAccess($var){
   $data=mysql_fetch_array(mysql_query("SELECT * FROM `acces` WHERE `id`='.$var.'")); 
   return $data;
}
getAccess($_SESSION['id']);

    $paramAcces = array(
        'comptesfinanciers' => array(
            'libelle'   => 'COMPTES FINANCIERS',
            'acces'     => $data['comptesfinanciers'],
            'lien'      => 'financier',
            'image'     => 'images/finances.png'
        )
    );

I have done a var_dump of $paramAcces which return

array(1) { ["comptesfinanciers"]=> array(4) { ["libelle"]=> string(18) "COMPTES FINANCIERS" ["acces"]=> NULL ["lien"]=> string(9) "financier" ["image"]=> string(19) "images/finances.png" } } (that are the ecpected values).

Here is the function for displaying what is in the array

/**
 * AFFICHAGE DE LA SECTION PARAMETRES SUR LA PAGE D'ACCUEIL
 */
 function affichParam($paramAccees){

     echo '<ul class="getcash-vmenu"><li><a href="index.php?p='.$paramAccees['lien'].'" class="active"><span class="t"><img src="'.$paramAccees['image'].'"> '.$paramAccees['libelle'].'</span></a></li></ul>';
 }

The trouble is that actualy it return to me an empty line.

I really do not know what I'm wrong doin:

I call the function like that:

<?php
affichParam($paramAccees)
?>

In a second time I will add more value, so I think I will have to do a for each loop or something like that.

But actualy I just would like to display the first record.

Any kind of help will be much apprecitaed

© Stack Overflow or respective owner

Related posts about php

Related posts about function