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 6709989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:56:50+00:00 2026-05-26T07:56:50+00:00

I have several links on one page which all direct to the same page,

  • 0

I have several links on one page which all direct to the same page, but each of them passes a different variable in the URL (http://sitename.com/thispage.php?id=3). I set new variables to true or false depending on which value is passed for “id”, then put the true/false variables in to set the default option on an option tag like so:

    if (isset($_GET['id']))
        $id = ($_GET['id']);

    if ($id = 4)
        $id4 = true;
    else
        $id4 = false;

    ...

    <option value="Value" selected="<?php echo "$id4"; ?>">
        Value
     </option>

Excuse me if it seems messy.

I’ve got 12 of those setup, one for each menu option. I can’t seem to get it to display the correct one as the default selection though, as it always selects the 2nd to last menu item.

  • 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-26T07:56:51+00:00Added an answer on May 26, 2026 at 7:56 am

    One thing you should correct is putting true and false in quotation marks, otherwise they will be converted from boolean to string and end up as a 1 or 0.

    Or you could replace the whole thing with this

    <option<?php if (isset($_GET['id']) && $_GET['id'] == 4){ echo ' selected'; } ?>>
        value
    </option>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page which lists several messages, and each of these messages has
I have several pages to do with several table on each page. I've got
I have a page which displays a different website (say www.cnn.com) in an iframe.
I have a page which contains several tables, and I would like to format
I have a page with several forms. I am trying to submit one of
I have a page with several check-boxes in a form, which when selected, filter
I have a modal popup with several links inside that have the :confirm and
I have to use javascript to make links instead of for several unimportant reasons,
We have several product lines built around a common core and currently maintain them
I have several large text files (30m+ lines, >1GB) which are being processed in

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.