WAMFT1 Posted January 22, 2014 Share Posted January 22, 2014 Hi Guys I am wanting to create a menu page which displays menu's based on if the menu field in the sql database has a yes or no in the contents by using an if statement. I have not had much success and would like some help to point me in the right direction. <?php include("../edb.php"); $id =$_REQUEST['id']; $result=mysql_query("SELECT * FROM `eusers` WHERE id='".$_SESSION['uid']."'"); if($MENUAdviser="Y") echo '<script type="text/javascript" src="ExtranetMenu.js"></script>'; if($MENUPAS="Y") echo '<script type="text/javascript" src="PASMenu.js"></script>'; if($MENUStaff="Y") echo '<script type="text/javascript" src="IntranetMenu.js"></script>'; if($MENUWebAdmin="Y") echo '<script type="text/javascript" src="WebAdminMenu.js"></script>'; ?> Quote Link to comment Share on other sites More sharing options...
Solution Mace Posted January 22, 2014 Solution Share Posted January 22, 2014 After setting the mysql_query you still have to call a mysql_fetch function with the result. use for an example: http://nl3.php.net/manual/en/function.mysql-fetch-assoc.php $result=mysql_query("SELECT * FROM `eusers` WHERE id='".$_SESSION['uid']."'"); while ($row = mysql_fetch_assoc($result)) { if($row['MENUAdviser']=="Y"){ echo '<script type="text/javascript" src="ExtranetMenu.js"></script>'; } if($row['MENUPAS']=="Y"){ echo '<script type="text/javascript" src="PASMenu.js"></script>'; } if($row['MENUStaff']=="Y"){ echo '<script type="text/javascript" src="IntranetMenu.js"></script>'; } if($row['MENUWebAdmin']=="Y"){ echo '<script type="text/javascript" src="WebAdminMenu.js"></script>'; } } Also, if you use if statements. Use the == operator instead of a single =. Otherwise it wont work. Quote Link to comment Share on other sites More sharing options...
WAMFT1 Posted January 22, 2014 Author Share Posted January 22, 2014 Awesome, thanks for your help Mace. Working like a charm. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.