Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 683041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:39:48+00:00 2026-05-14T01:39:48+00:00

Below is my example script: <li><a <?php if ($_GET[‘page’]==’photos’ && $_GET[‘view’]!==projects||!==forsale) { echo (href=\#\

  • 0

Below is my example script:

<li><a <?php if ($_GET['page']=='photos' && $_GET['view']!=="projects"||!=="forsale") { echo ("href=\"#\" class=\"active\""); } else { echo ("href=\"/?page=photos\""); } ?>>Photos</a></li>
<li><a <?php if ($_GET['view']=='projects') { echo ("href=\"#\" class=\"active\""); } else { echo ("href=\"/?page=photos&view=projects\""); } ?>>Projects</a></li>
<li><a <?php if ($_GET['view']=='forsale') { echo ("href=\"#\" class=\"active\""); } else { echo ("href=\"/?page=photos&view=forsale\""); } ?>>For Sale</a></li>

I want the PHP to echo the “href=”#” class=”active” only when it is not on the two pages:

?page=photos&view=forsale

or

?page=photos&view=projects

I’ve also tried this and it doesnt work:

<li><a <?php if ($_GET['page']=='photos' && ($_GET['view']!=='projects' || $_GET['view']!=='forsale')) { echo ("href=\"#\" class=\"active\""); } else { echo ("href=\"/?page=photos\""); } ?>>Photos</a></li>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:39:48+00:00Added an answer on May 14, 2026 at 1:39 am

    In addition to the problem cletus pointed out you also have an issue with the precedence of the operators. && has a higher precedence than ||. Therefore

    if (
      $_GET['page']=='photos'
      && $_GET['view']!=="projects"
      || $_GET['view']!=="forsale"
    )
    

    is equivalent to

    if (
      ( $_GET['page']=='photos' && $_GET['view']!=="projects" )
      || $_GET['view']!=="forsale"
    )
    

    But you obviously want

    if (
      $_GET['page']=='photos'
      && ( $_GET['view']!=="projects" || $_GET['view']!=="forsale" )
    )
    

    Maybe not for two alternatives but if you have more options you might want to consider using !in_array(). e.g.

    if (
      'photos'=$_GET['page']
      && !in_array($_GET['view'], array("projects","forsale"))
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have example of code below. <script type=text/javascript src=assets/scripts/somescript.php>. </script> So, will my browser
Is there a difference between the two examples below for beginning a Perl script?
The example below throws an InvalidOperationException, Collection was modified; enumeration operation may not execute.
In my example below I'm using a dijit.form.DateTextBox : <input type=text name=startDate dojoType=dijit.form.DateTextBox constraints={datePattern:'MM/dd/yyyy'}
In the example below I have a ListBox with dozens of font names in
I usually do something like the example below when I need to return error
How can I select the good method (I have in the example below show
I am working with an object which has sub objects within (see example below).
Working with a latex document with eps images as in the example below... \documentclass[11pt]{paper}
I'm trying to perform a group by action on an aliased column (example below)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.