Passing multiple values form URL to PHP
Results 1 to 3 of 3

Thread: Passing multiple values form URL to PHP

  1. #1
    Senior Member
    Join Date
    Jun 2000
    Posts
    65,357

    Passing multiple values form URL to PHP

    How do I pass multiple values to php form the url. I'm trying to do a ID and Page Number system. So, I can say like document 1 page 4. Example http://load.phtml?id=1&page=4
    and the document with id:1 will load the page with the vaule page_num:4.

    Thanks for your help in advance sorry for being such a newbie.



    <?php

    if($id$page) {

    @MYSQL_CONNECT("localhost","","");

    @mysql_select_db("mx6power");

    $query = "select page_num,head,path,content from mx6power where id=$id";
    $result = @MYSQL_QUERY($query);

    $page = @MYSQL_RESULT($result,0,"page_num");
    $heading = @MYSQL_RESULT($result,0,"head");
    $paths = @MYSQL_RESULT($result,0,"path");
    $contents = @MYSQL_RESULT($result,0,"content");

    echo "<head><title>$heading</title></head>";


    echo $id;
    echo "<br>";
    echo $page;
    echo "<br>";
    echo $heading;
    echo "<br>";
    echo $paths;
    echo "<br>";
    echo $contents;
    echo "<br>";


    );
    ?>

  2. #2
    hubris, loathing, technol
    Join Date
    Mar 2001
    Posts
    139

    RE: Passing multiple values form URL to PHP

    well you can use header, ie:

    header("Location: mypage_$id.php?page=$page_num");

    i'm not really sure what your desired result is, but that may help

    -frymaster


  3. #3
    Senior Member
    Join Date
    Jun 2000
    Posts
    65,357

    RE: Passing multiple values form URL to PHP

    I managed to pull out multiple variables from a URL with the following:

    if the URL is http://...run.php?rider=terje&style=goofy

    and you want the variables 'rider' and 'style'...

    $desired_variable = $HTTP_GET_VARS['rider'];
    $desired_variable2= $HTTP_GET_VARS['style'];


    don't worry about newbie-ism.. how are you supposed to learn otherwise



    Adam wrote:
    -------------------------------
    How do I pass multiple values to php form the url. I'm trying to do a ID and Page Number system. So, I can say like document 1 page 4. Example http://load.phtml?id=1&page=4
    and the document with id:1 will load the page with the vaule page_num:4.

    Thanks for your help in advance sorry for being such a newbie.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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