SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict animgirl's Avatar
    Join Date
    Oct 2003
    Location
    Land of the free, home of the brave
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Going to a bookmark within an include file

    Hello,

    My scenario is a little confusing so I'll do the best I can to explain.

    I have a subnav on my page with links similar to this:
    Code:
    <a href="<?php echo $_SERVER['PHP_SELF']; ?>?class=class_name"<?php if ($class == 'class_name') echo ' class="highlight"'; ?>>Class</a>
    On this page I also have an if-else statement that starts like this:
    Code:
    <?php 
    $class = $_GET['class']; 
    if($class == "class_name") { 
         include("myfile.php");   
    }
    Within "myfile.php" I have bookmarks for some of the text sections:
    Code:
    <a name="class_name">Class Name</a
    I want the if-else statement to not only include myfile.php, but to go directly to the bookmark within myfile.php.

    How can I do this? I hope I explained it well.

    Thank You,
    Elise Henley

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    San Francisco
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm let's see - I think I may understand what you want. But I am not sure you need the bookmark taken care of by the conditional. Would you just need to include the hash in the href?

    PHP Code:
    <a href="<?php echo $_SERVER['PHP_SELF']; ?>?class=class_name#class_name"<?php if ($class == 'class_name') echo ' class="highlight"'?>>Class</a>
    Is this what you were thinking?

  3. #3
    SitePoint Addict animgirl's Avatar
    Join Date
    Oct 2003
    Location
    Land of the free, home of the brave
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well that was insanely simple. Thought I had tried that before...
    I tried it just now and it works

    Thanks
    Elise Henley


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
  •