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
    New Coder
    Join Date
    Feb 2010
    Posts
    39
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How to create an active link in a PHP search result?

    Hi all,

    I am trying to make a link from a PHP search result. To see what I'm trying to do, you can go to this page that I'm working on. You can search by "730000450." I want to link the account number on the results to another results page that has more detailed information about that specific account. I want to link it to this page that'll have specified results on it.

    How do I create a link in PHP search results?

    Thank you!
    Last edited by WA; 07-14-2010 at 08:20 PM.

  • #2
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    You can use a while loop to do this. Basically it'd look like this

    PHP Code:
    echo "<a href=\"accounts.php?id=$accountid\">$accountid</a>"
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #3
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    The same as you'd link anything else. In your search page, for each result returned, insert a hyperling pointing to the page with an id which it van use to pull the respective record. Something along the lines of:

    Code:
    <a href="http://www.wagonerassessor.com/formresults.html?id=sql_query_id_here">View full results</a>
    Then, on the formresults page, extract the id:

    Code:
    $id = intval($_GET['id']);
    and run the db query for that id, (after validating and sanitising the id fully, of course).


  •  

    Posting Permissions

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