SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot Dionysis's Avatar
    Join Date
    Jan 2004
    Location
    Socal
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    easy question, need to display something when...

    Hey,
    i need to display a peice of code when a user clicks a link. For example, my site has a section that i want to sort into 4 different peices. now a user can click "peice 1, peice 2, peice 3, peice 4" and i want that information to be displayed.

    I can't figure out the best method to do so, i was thinking of inserting some css like <style "display:none;"> for the 3 that arn't selected, but then i couldn't think of a good way to organize it all.

    any input?

  2. #2
    SitePoint Enthusiast nathanj's Avatar
    Join Date
    Dec 2004
    Location
    Perth, WA, Australia
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe you require a switch() statment? Check for different vaules "p" which is passed via GET. For example:

    PHP Code:
    <?php

    switch ($_GET['p]) {
    case 1:
        echo '
    piece 1';
        break;
    case 2:
        echo '
    piece 2';
        break;
    case 3:
        echo '
    piece 3';
        break;
    case 4:
        echo '
    piece 4';
        break;
    default:
        echo '
    no piece selected';
    }

    ?>
    Put that into show.php and then open up http://www.example.com/show.php?p=1 and it will show "piece 1".

  3. #3
    SitePoint Zealot Dionysis's Avatar
    Join Date
    Jan 2004
    Location
    Socal
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks.!


    Quote Originally Posted by nathanj
    Maybe you require a switch() statment? Check for different vaules "p" which is passed via GET. For example:

    PHP Code:
    <?php

    switch ($_GET['p]) {
    case 1:
        echo '
    piece 1';
        break;
    case 2:
        echo '
    piece 2';
        break;
    case 3:
        echo '
    piece 3';
        break;
    case 4:
        echo '
    piece 4';
        break;
    default:
        echo '
    no piece selected';
    }

    ?>
    Put that into show.php and then open up http://www.example.com/show.php?p=1 and it will show "piece 1".

  4. #4
    SitePoint Addict trogdor1024's Avatar
    Join Date
    Oct 2004
    Location
    New Jersey
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    // typo in switch statement
    switch ($_GET['p']) {
    .
    .
    .


  5. #5
    SitePoint Enthusiast nathanj's Avatar
    Join Date
    Dec 2004
    Location
    Perth, WA, Australia
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by trogdor1024
    PHP Code:
    // typo in switch statement
    switch ($_GET['p']) {
    .
    .
    .

    Oops.


Bookmarks

Posting Permissions

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