I met some trouble with a php function customed by myself.
In fact I would like to separated the html code from the php treatment, so Instead of displaying each element one after one, I decided to put my menu into an array.
So here is my array:
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'
),
'journaux' => array(
'libelle' => 'JOURNAUX',
'acces' => $data['journaux'],
'lien' => 'journaux',
'image' => 'images/newspaper.png'
)
);
/**
* AFFICHAGE DE LA SECTION PARAMETRES SUR LA PAGE D'ACCUEIL
*/
function affichParam($paramAccees){
foreach ($paramAcces as &$parametres) {
echo '<ul class="getcash-vmenu"><li><a href="index.php?p='.$parametres['lien'].'" class="active"><span class="t"><img src="'.$parametres['image'].'"> '.$parametres['libelle'].'</span></a></li></ul>';
}
}
The trouble is that when I call this function like that in the main page index.php
affichParam($paramAccees)
It does not display anything except a semicolon like that ;
Anykind of help or advice will be much appreciated.
You have a typo in this code block
Change the first line to this:
EDIT:
And also what @GBD commented, call
affichParam($paramAcces)correctly.