在php中用于显示菜单的功能

问题描述:

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

我遇到了一个我写过的函数的麻烦。 p>

实际上 我有一个数组,其中我有不同的自定义值。 p>

我想显示结果,所以这是我的函数 p>

  function getAccess($ var){
 $ data = mysql_fetch_array(mysql_query(“SELECT * FROM`access` WHERE`id` ='。$ var。'”));  
返回$ data; 
} 
 
NetAccess($ _ SESSION ['id']); 
 
 $ paramAcces = array(
'comptesfinanciers'=&gt; array(
'libelle'=&gt;'COMPTES  FINANCIERS',
'acces'=&gt; $ data ['comptesfinanciers'],
'lien'=&gt;'financier',
'image'=&gt;'images / finances.png'
)\  n); 
  code>  pre> 
 
 

我做了一个$ paramAcces的var_dump,它返回 p>

  array(1){[  “comptesfinanciers”] =&GT;  array(4){[“libelle”] =&gt;  string(18)“COMPTES FINANCIERS”[“acces”] =&gt;  NULL [“lien”] =&gt;  string(9)“financier”[“image”] =&gt;  string(19)“images / finances.png”}}(这是预期的值)。
  code>  pre> 
 
 

这是用于显示数组中的内容的函数

  / ** 
 * AFFICHAGE DE LA SECTION PARAMETRES SUR LA PAGE D'ACCUEIL 
 * / 
函数affichParam($ paramAccees){
 
 echo'&lt  ; ul class =“getcash-vmenu”&gt;&lt; li&gt;&lt; a href =“index.php?p ='。$ paramAccees ['lien']。'”class =“active”&gt;&lt; span class  =“t”&gt;&lt; img src =“'。$ paramAccees ['image']。'”&gt;  '。$ paramAccees ['libelle']。'&lt; / span&gt;&lt; / a&gt;&lt; / li&gt;&lt; / ul&gt;'; 
} 
  code>  pre> 
 
  

麻烦的是,它实际上给我一个空行。 p>

我真的不知道我错了什么: p>

我调用这样的函数: p>

 &lt;?php 
affichParam($ paramAccees)
?&gt; 
  code>  pre> 
 
  

第二次我将添加更多的值,所以我想我必须为每个循环或类似的东西做一个。 p>

但实际上,我只是希望显示第一条记录。 p>

任何形式的帮助都会得到很多赞赏 p> DIV>

lien is apart of the comptesfinanciers array which is apart of the paramAccees array, which should be reflected as so:

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