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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:00:23+00:00 2026-05-18T05:00:23+00:00

A complete beginners question. I have a large number of divs (>80) on a

  • 0

A complete beginners question.
I have a large number of divs (>80) on a page (page2.php) and what I would like to do is open page1.php, click on a link to open page2.php and show only one of these divs depending on which link was clicked.

I have a basic working version of this by adding an if else to the divs. I’ve only done this on 5 of the divs so far and it works but it also seems a fairly in-eloquent way of doing things.

Page 1:

 <a href="page2.php?id=r0101">this is a link</a>

Page 2:

<?php 
$divID = $_GET['id'];
?>

<div id="r0101" <? if($divID == r0101): ?>class="show"<? else: ?>class="hidden"<? endif; ?> >

This then applies a css class to hide or show the div.
Would it be possible to have a function or whatever at the top of the page that takes the id from the url, figures out that there is a div with that id also, show it and hide all the others? This is probably an easy thing to do but it has me stumped.

Any help greatly appreciated.
Thanks.

  • 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-18T05:00:24+00:00Added an answer on May 18, 2026 at 5:00 am

    Let alone the divs and work on css (as you relay on that to hide/show the divs).
    You can generate not only markup but css stylesheet too. Use a similar one (put it at
    the end of your head section). And let the browser do the work for you 😉

    <style type="text/css">
        div {
            display: none;
        }
    
        div#<?php echo $_GET['id']; ?>:{
            display: block;
        }
    </style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Complete beginners question here, literally. I'm interested in developing Windows 8 Apps so I've
I am a complete beginner in Python, and would like to start learning it
I state that I am a complete beginner to LDAP. I have to let
I have a rails question that I have been unable to find an answer
I know its a big question but I'm a complete beginner. I've limited experience
I realize that this is a question that will probably not have a single
I'm beginner - mid range when it comes to php knowledge and complete beginner
This is probably an elementary question. However, I have completed reading the 5th Chapter
I'm a complete beginner to Apple's Xcode, but I have followed the Xcode documentation
Complete beginner to Rails here: In Rails: I have a Model Post, which hasmany

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.