0

I need to query data from a table accourding to user level to genarate a menu list for different user levels, the code worked well with (session->username) but when I changed to (session->user_level) it does not want to work.

Any help will be appreciated.

Here is my code:

<?php
if($session->logged_in){
 
$user = ($session->userlevel);
$t_user = trim($user);

$result = mysql_query("SELECT * FROM menu_1 WHERE '$t_user' = '1'");

while($row = mysql_fetch_array($result))
{					
echo"<a href=\"".$row['href']."\">".$row['item']."</a>";
echo"<br />"; 
}

}
?>

Thank you in advance.

Max

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by trilithon
0

I figured out how to do it. Here is the code if any body would be interested.

<?php
include("include/session.php");

if($session->logged_in){
   if($session->isAdmin()){
      $test = "level9";
   }
      if($session->isUser8()){
      $test = "level8";
   }
      if($session->isUser7()){
      $test = "level7";
   }   
      if($session->isUser6()){
      $test = "level6";
   }   
      if($session->isUser5()){
      $test = "level5";
   }   
      if($session->isUser4()){
      $test = "level4";
   }   
      if($session->isUser3()){
      $test = "level3";
   }   
      if($session->isUser2()){
      $test = "level2";
   }   
       if($session->isUser1()){
      $test = "level1";
   }    
}
$query= "select * from menu_1 WHERE $test = '1'";
$list=mysql_query($query);
while($record=mysql_fetch_array($list)){	
echo "
<tr>		
<td>".$record['item']."</td>		
<td>".$record['href']."</td>		
</tr>
<td>";

}
	
?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.