dpg2905 2012-11-19 16:50
浏览 24
已采纳

在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

  • 写回答

1条回答 默认 最新

  • dongposhi8677 2012-11-19 16:57
    关注

    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>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我想在一个软件里添加一个优惠弹窗,应该怎么写代码
  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流