Validation from DB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ok, here is my problem. I have this website where my user will log in.

I have this function that list all the permissions possible

function lista_permissoes() {

    $result = mysql_query("select * from permissoes ORDER BY ordem");
    while ($row4 = mysql_fetch_array($result,MYSQL_ASSOC)) {
 $permissoes[] = $row4;
    }
   return $permissoes;
};

And this function that., I suppose, should check if the group that the
person belongs have this permission or not
function validar($grupo,$perm) {
    $permissao = mysql_query("select id_permissoes from grupos_permissoes
where id_grupos = $grupo") or die ('query failed');
 $row = mysql_fetch_array($permissao);
 $acesso = 0;
 for ($i = 0 ; $i<=sizeof($row); $i++){
 if (array_key_exists($perm, $row)) {
    $acesso = 1;
 }
}
return $acesso;
}

So, if the permission in question belongs to the group, it would return
$acesso 1, right? So, putting the 2 of them together, it would work like
this:
$permis = lista_permissoes();
for($i=0; $i<=sizeof($permis); $i++) {
$permiss = $permis[$i];
//here the SESSION is the id of the group of the user
 $aux = validar($_SESSION['ciranda']['id_grupo'],$permiss['id']);
 if ($aux) {
  ?>
          <a href="index-2.php?permissao=<?= $permiss['id'] ?>"
class="permiss">
          <?= $permiss['nome']?>
          </a><hr align="left" width="150">
          <?
 }
}

Well, I dont get any error, but I can get only the first permission
validated... its like the function is not looping back. Can anyone see what
is wrong?

Thank you in advance,

Dani


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.481 / Virus Database: 277 - Release Date: 13/5/2003



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux