#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Canada
    Posts
    35
    Rep Power
    15
    Hello,
    I have a loop to create a SQL query after multiple checkboxes have been selected:

    $query="select * from $usertable where (";
    //query

    for($a=0;$a<$nb;$a++){
    //use a loop for building the query
    $query.="location LIKE '$location' AND field LIKE '$field' AND position LIKE '$position[$a]'";

    if($a!=$nb-1){
    //skip OR if it is last item.
    $query.= " OR ";
    }
    else{
    //skip OR if it is last item.
    $query.= ") ORDER BY date_posting DESC";
    }
    }


    Is there a way to pass the variable $query (meaning I don't have to build the query again) through the URL?
    I tried
    PRINT "<a href='$PHP_SELF?query=$query'</a>";
    but it doesn't work
  2. #2
  3. No Profile Picture
    Viper_SB
    Guest
    Devshed Newbie (0 - 499 posts)
    for($a = 0; $a < $nb; $a++){
    //use a loop for building the query
    $whereinfo .= "location LIKE '$location' AND field LIKE '$field' AND position LIKE '$position[$a]'";
    if($a != $nb - 1){
    //skip OR if it is last item.
    $whereinfo .= " OR ";
    }
    }
    // Puts it all together
    //query
    $query = "SELECT * FROM $usertable WHERE ($whereinfo) ORDER BY date_posting DESC";

    // Encode the url so that it passes through without messing up
    $query = urlencode($query);

    echo "<a href="index.php3?query=$query">current page</a>";

    // use these once you pass it through to decode and remove the slashes
    $query = urldecode($query);
    $query = stripslashes($query);

    NOTE: There is a 2083 char limit to how long a url can be.
    There also might be a better way to pass the varible to the next page.

    Viper_SB

    [This message has been edited by Viper_SB (edited August 28, 2000).]

Similar Threads

  1. Passing POST variables
    By rlorenzo in forum PHP Development
    Replies: 11
    Last Post: June 6th, 2004, 03:00 PM
  2. Replies: 7
    Last Post: February 16th, 2004, 03:55 PM
  3. help with assigning variables, variable passing/ retrieval
    By pinkipodmini in forum PHP Development
    Replies: 0
    Last Post: February 13th, 2004, 10:40 PM
  4. passing variables with url
    By jackass in forum PHP Development
    Replies: 5
    Last Post: January 28th, 2004, 06:19 PM
  5. php variables in java passing through the url
    By panahi in forum Java Help
    Replies: 0
    Last Post: January 23rd, 2004, 04:50 PM

IMN logo majestic logo threadwatch logo seochat tools logo