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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Posts
    135
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Dynamically setting Variables?

    I'm trying to add some text to a url based upon if it's post variable exists.

    Like, if they goto the events page, it will add the highlight code to that link in the menu.

    $["$selected"]//My bad attempt

    How do I dynamically choose which variable gets "class=\"selected\"" set to it? The variables are $featured, $events, and $past.

    Code:
    if (!isset($_GET["page"])){
    $selected = $_GET["page"];
    $["$selected"] = "class=\"selected\""; //The code that doesn't work.
    }
    
    
    echo "<a href=\"index.php?page=featured\" $featured>Featured Events</a></li><li>
    <a href=\"index.php?page=events\" $events>All Events</a></li><li class=\"last\">
    <a href=\"index.php?page=past\" $past>Past Events</a></li>
    ";
    Last edited by iceflyin; 08-15-2007 at 06:41 AM.

  • #2
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    its just
    PHP Code:
    $$selected "class=\"selected\"";

    if 
    that doesnt work you cal always try:
    ${
    $selected} = "class=\"selected\""

    -Adam
    Why not thank me?

    http://adamsworld.name

  • #3
    Regular Coder
    Join Date
    Jul 2007
    Posts
    135
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ahh, knew it was something like that... Thanks!


  •  

    Posting Permissions

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