...

View Full Version : Hiding/showing div



silviya
10-24-2009, 07:41 PM
Hello there! I'm new to php and I'm having hard times with what I have to do.
I have a page, let's say articles.php. There are 3 let's say articles with a a brief explanation and a link "show more information". Clicking the link, using GET, im making articles.php?id=1. I use database. So, what i want is when showing id 1 to have everything that used to be in the content div to "disappear" and and load only what comes from the database. So far, I only get the data but everything remains the same. Is there a way to do it with php only or i'll need to hide the data with css or javascript?

codyodell
10-24-2009, 08:10 PM
PHP does not handle what your explaining. If you don't know JS very well, I would suggest looking at jQuery (http://jquery.com/)

Here's some sample code to help you out:



$(document).ready( function(){
$('#link_id').click( function(){
$(this).toggle();
});
});

silviya
10-24-2009, 08:17 PM
Hm, I thought so but I wanted to ask. The thing is i dont need exactly hiding and showing, i need loading and unloading dependint on the url. Thanks :)

silviya
10-24-2009, 09:32 PM
There is a question again.
As i said i'll have 3 divs for example with 3 links for more info. Clicking on one link should display the data from the DB and hid the other 2 divs. Basically we ramain on the same page So, it should hide the two divs on click but at the same time that click has something to do, it does load data from the DB.

Haaskis
10-25-2009, 10:40 AM
I'm new to php aswell, but if you want to hide other div's and load data to only one, you could try to use $_GET and IF ;).

Check for div number from address bar:

$show = $_GET['show'];

Make your links like this:


mysite.php?show=1
mysite.php?show=2
mysite.php?show=3


Showing contents, this will only show 1 div though:


if ($show == "1") {
echo "<div class='yourclass'> input your loading for first div1 here </div>";
} elseif ($show == "2") {
echo "<div class='yourclass'> input your loading for first div2 here </div>";
} elseif ($show == "3") {
echo "<div class='yourclass'> input your loading for first div3 here </div>";
}


On the otherhand you could use IF to load data inside the div:


<div class="yourclass"> <? if ($show == "1") your loading stuff for div1 here; ?></div>
<div class="yourclass"> <? if ($show == "2") your loading stuff for div2 here; ?></div>
<div class="yourclass"> <? if ($show == "3") your loading stuff for div2 here; ?></div>


Hope I could help!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum