Search the Community
Showing results for tags 'if statements'.
-
I am trying to call a user defined function in an if statement when the condition is true. if($number_of_rows_after>$number_of_rows_before) { myFunction(); echo "this my if"; } else{ echo "this is my else"; } myFunction() is getting called regardless of whether or not my condition is true or false so i will have "this is my else" echoed and myFuction() runs
-
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>'; ?>
-
Hi everyone, I'm in the process of developing a site for my school which allows students and teachers to log in to do different things. At the moment I'm working on redirecting people from a page that requires them to be logged in as teachers. I've got a bit of code that works already which directs people away from the page and gives them a message. That code is here: <?php session_start(); if (empty($_SESSION['userName']) || $_SESSION['member_type'] == 'Student' ) { $_SESSION['msg'] = 'You must be a teacher to access the teachers.php page'; header("Location: login_required.php"); die(); } ?> However, I'd like to tweak this a bit so the message is customised, based on whether the person is: i) currently logged in as a student ii) not logged in at all iii) or else, if they're logged in as a teacher, simply displaying the page as normal. The code I've tried is this: <?php session_start(); if (empty($_SESSION['userName']) ) { $_SESSION['msg'] = 'You must be a teacher to access the teachers.php page. You are currently not logged in.'; header("Location: login_required.php"); die(); } else if ($_SESSION['member_type'] == 'Student'); { $_SESSION['msg'] = 'You are logged in as a student, but you must be a teacher to access the teachers.php page'; header("Location: login_required.php"); die(); } ?> This works by giving the correct messages to people who are either students or who are not logged in. However, if I am logged in as a teacher, I am still given the message saying "You are logged in as a student" etc...rather than having access to the page. I'd be greatly appreciative if anyone could point out my error. Thanks greatly, Dave
-
Hello, I can't achieve what I am looking to do here: <html> <head> <title>PHP Weekend Challenge</title> </head> <body> <?php \\*if month = december and day = 23rd and time=19:00-23:59 echo "Good Evening, tomorrow is Christmas Eve!" or if month = december and day = 24th and time=19:00-23:59 echo "Good Evening, tomorrow is Christmas Day!" else echo "It's not Christmas so too bad - it's just another 7 day working week!"*\\ ?> </body> </html> I'm a newbie so please assume I know nothing about PHP and provide as much explanation as you can for the solutions you give. I have read around on different websites and I find it exceptionally difficult to understand them because of my dyslexia and dyscalculia. Please advise :-) Thanks and Kind Regards, Beanie
- 4 replies
-
- if statements
- date function
-
(and 3 more)
Tagged with: