Php url dizeden gizle / göster divs

0 Cevap php

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.

Ben divlere bir else if ekleyerek bu temel bir çalışma sürümü var. Ben sadece şimdiye kadar divs 5 Bu yaptık ve çalışır ama aynı zamanda şeyler yapmanın oldukça in-beliğ bir şekilde görünüyor.

Sayfa 1:

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

Sayfa 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.

0 Cevap