-
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
:confused:
-
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
-
thanks, I'll give it a try!;)
-
...and on a similar note: if you pass the variable via a POST method of a form, use $_POST['varname'].