How to set a link on a page like an anchor

Discussion in 'PHP' started by lemorris, Jan 11, 2006.

  1. #1
    Hi all.

    I'm trying to have a text link go to a specific paragraph on a page.

    I have this:

    <td width="47%"><?php
    script
    ?>
    <a href="#secu">Security</a>
    <?php
    script
    ?>
    </a></td>
    HTML:


    example. If the user clicks on the security link I would like the page to scroll to or jump to that paragraph.

    Here's the page:
    http://www.formulafirstracing.com/catalog/policies_info.php

    I'd like my page to move to the anchor point much like html.

    I am new to PHP

    Thanks

    -Lemorris
     
    lemorris, Jan 11, 2006 IP
  2. minstrel

    minstrel Illustrious Member

    Messages:
    15,082
    Likes Received:
    1,243
    Best Answers:
    0
    Trophy Points:
    480
    #2
    :confused:

    Why do you need to do it in PHP, since your using PHP embedded in HTML anyway?

    <td width="47%">
    {whatever}
    <a href="#secu">Security</a>
    </td> 
    
    ....
    
    <p>
    <a name="secu">Security</a>
    {text here about security}
    </p>
    
    Code (markup):
     
    minstrel, Jan 11, 2006 IP
  3. lemorris

    lemorris Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the response Minstrel,

    on the Returns link I have this:

    
    <td><a href="#retu">Returns</a></td>
    HTML:
    Then below for the returns text I have:

    
    <p><strong><a name="retu" id="retu"></a><br>
                              Returns</strong></p>
    HTML:
    The link doesn't go to that marker instead it takes me to my index.php page with this in the address bar:

    http://www.formulafirstracing.com/catalog/#retu

    Click returns on this page

    http://www.formulafirstracing.com/catalog/policies_info.php

    to see what it does.

    Any ideas? The guy who owns the site says I can just type "Read our policies below" and move on, but I thought I'd give it one more shot before I threw in the towel.

    Thanks in advance.

    -Lemorris
     
    lemorris, Jan 12, 2006 IP
  4. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
  5. minstrel

    minstrel Illustrious Member

    Messages:
    15,082
    Likes Received:
    1,243
    Best Answers:
    0
    Trophy Points:
    480
    #5
    There's no problem with the code you've posted that I can see. That suggests that there is a problem with the code around it, PHP or HTML - check to ensure that the "<a name="retu" id="retu"></a>" part isn't inside some sort of loop or script you haven't closed, or an improperly nested table cell or something.
     
    minstrel, Jan 12, 2006 IP
  6. lemorris

    lemorris Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    That did it Dave!

    Thank you!

    The help was much appreciated...I'll lurk happily now. :)

    -Lemorris
     
    lemorris, Jan 12, 2006 IP