Results 1 to 5 of 5

Thread: adding variables to search

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    From the UK
    Posts
    422

    Question adding variables to search

    if i have a line such as:

    HTML Code:
    http://www.site.net/index.php?s=1
    in my browser and i want to be able to click on another link in my website and end up with:

    HTML Code:
    http://www.site.net/index.php?s=1&t=2
    what is the correct method to do this via an anchor tag?

    i tried:

    PHP Code:
    <?php echo $PHP_SELF;?>?t=<?php echo $tnum;?>">
    but as you will know that only returned:

    HTML Code:
    http://www.site.net/index.php?t=2
    so what is the correct way? (without using cookies if possible)

    many thanks for your help,

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: adding variables to search

    Im not sure what you asking, but here is how you add another variable:

    PHP Code:
    <?php echo $PHP_SELF?>?t=<?php echo $tnum?>&amp;s=<?php echo $snum?>
    My usual boring signature: Something

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    From the UK
    Posts
    422

    Re: adding variables to search

    what i mean is that

    if my url is:

    this:

    <?php echo $PHP_SELF; ?>
    still = http://www.site.net/index.php

    ie.

    <?php echo $PHP_SELF;?>?t=<?php echo $tnum;?>">
    will just do:

    but i want to add $t onto whatever the url is (and keep any other variables already there intact)

    hope that makes sense,

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: adding variables to search

    Use the $_SERVER['QUERY_STRING'] variable.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: adding variables to search

    Validate all variables in $_GET and then use the results to generate a new query string for the hyperlink.

Posting Permissions

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



Click Here to Expand Forum to Full Width