Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Hiding/showing div

    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?

  • #2
    New Coder
    Join Date
    Feb 2006
    Posts
    18
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Try jQuery

    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:

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

  • Users who have thanked codyodell for this post:

    silviya (10-24-2009)

  • #3
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #4
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

  • #5
    New to the CF scene
    Join Date
    Oct 2009
    Location
    Finland
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    PHP Code:
    $show $_GET['show']; 
    Make your links like this:
    PHP Code:
    mysite.php?show=1
    mysite
    .php?show=2
    mysite
    .php?show=
    Showing contents, this will only show 1 div though:
    PHP Code:
    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:
    PHP Code:
    <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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •