PHP to change content on page with click

Discussion in 'PHP' started by cluongo18, Nov 23, 2011.

  1. #1
    I'm running a static website with some php put into it. I'm a very basic beginner in PHP and I'm wondering how I could do the following:

    On a page of my website I wan't to have 3 links. Each link I want to display different
    content when clicked, but stay on the same page.

    For example,

    You click a link and go to someones portfolio on their website. They're 3 more links on the portfolio page: "Websites" "Graphics" "Audio"

    When you click "Websites", I would want the content on the page to change to "websites" content, if you click "graphics" I want the content to change to "graphics" content - all while staying on the "portfolio" page.

    So I know I would need 3 seperate php files for each link within the portfolio page to hold the content. Then use an includes on the page? I'm stuck!

    I imagine it's super easy I'm just having some massive brain tard problems now.
     
    Solved! View solution.
    cluongo18, Nov 23, 2011 IP
  2. #2
    sandhee_tube, Nov 23, 2011 IP
  3. alexfad20

    alexfad20 Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Use JavaScript for this
     
    alexfad20, Nov 23, 2011 IP
  4. alltexaspoker

    alltexaspoker Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You must use an AJAX request for that, using jQuery, it would look something like this:
    $("#websites").click(function(){
    $.get("websites.php", function(data){
    $("#divYouWantTheContentInside").html(data);
    });
    });

    And that's it.
     
    alltexaspoker, Nov 24, 2011 IP