Jump to content

If statement help please.


topflight

Recommended Posts

Hello on my site I have 2 content boxes. 1 is for the main content (which is the biggest one) and the second one is for a sub navigation (which is a small box). I am trying to write an IF statement so that if ?content=(a certain value) then the sub navigation which is box #2 will display that page sub navigation. Here is what I have so far.

 

<?
session_start(); 
include'dbconfig.php'; 

$content = $_GET[content];

if($content != 'hub' or $content !='hr' or $content !='crewcenter'){include'content/newmembers.php';}

//Displays side menu for HR navigation

if($content == 'hr'){?>

<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><div align="center"><strong><a href="#">Roster</a></strong></div></td>
  </tr>
  <tr>
    <td><div align="center"><strong><a href="#">Staff</a></strong></div></td>
  </tr>
  <tr>
    <td><div align="center"><strong><a href="#">Job Openings</a></strong></div></td>
  </tr>
  <tr>
    <td><div align="center"><strong><a href="#">Forms</a></strong></div></td>
  </tr>
</table>

<? }elseif( $content == 'crewcenter' }{



}

?>

 

The main problem I am trying  to fix is that when I go the HR page it shows the newmembers.php and it still shows the hr submenu, I just want  to show the HR submenu. This is the same problem for the crew center. Please help.

 

Thanks in Advanced.

Link to comment
https://forums.phpfreaks.com/topic/187891-if-statement-help-please/
Share on other sites

your if statement:

if($content != 'hub' or $content !='hr' or $content !='crewcenter'){include'content/newmembers.php';}

will always be true. Think about it. Its asking, If $content doesn't equal this, or doesn't equal that. If it is equal to "hub" than it won't be equal to "hr" so it will still include newmembers.php

 

perhaps you mean to use and instead of or

if($content != 'hub' && $content !='hr' && $content !='crewcenter'){include'content/newmembers.php';}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.