|
-
Jun 21st, 2002, 04:49 AM
#1
Thread Starter
Hyperactive Member
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
-
Jun 21st, 2002, 05:52 AM
#2
Fanatic Member
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
-
Jun 23rd, 2002, 06:45 PM
#3
Thread Starter
Hyperactive Member
thanks, I'll give it a try!
Multimedia Programmer
Uses VB.Net and MySQL
-
Jul 1st, 2002, 08:48 PM
#4
Member
...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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|