Results 1 to 4 of 4

Thread: passing of variables

  1. #1

    Thread Starter
    Hyperactive Member phutie's Avatar
    Join Date
    Jan 2002
    Location
    Somewhere in Asia
    Posts
    295

    passing of variables

    Hi,

    I declared my variable as global and used it to hold a query result but the variable is not passing its value to another php page where I need it again for another query something like this:

    1st php page:
    global $comp

    $result = "Select Company from dbtable where Name = ABC";
    $comp = $mysql_query($result);


    2nd php page:

    $query = "Select Branch from dbtable2 where Company = '$comp'";

    pls help






    Multimedia Programmer
    Uses VB.Net and MySQL

  2. #2
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    okay to do that you will need to pass $comp in the link that goes to php page 2.

    PHP Code:
    <a href="phpPage2.php?comp=<?php echo "$comp"?>">Go to Page 2</a>
    Then to grab that variable you would use the following in PHP Page 2:
    PHP Code:
    $comp $_GET['comp'];
    $query "Select Branch from dbtable2 where Company = $comp"// no single quotes 
    -Matt
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  3. #3

    Thread Starter
    Hyperactive Member phutie's Avatar
    Join Date
    Jan 2002
    Location
    Somewhere in Asia
    Posts
    295
    thanks, I'll give it a try!
    Multimedia Programmer
    Uses VB.Net and MySQL

  4. #4
    ...and on a similar note: if you pass the variable via a POST method of a form, use $_POST['varname'].

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