Page 1 of 1

Receive a parameter from another file

Posted: Tue Jul 05, 2005 7:57 am
by mustafamisir
Hi,

In a .php page, I am making a list of some materials which have in formation in MySQL. And there is a link which calls another .php file with some parameters. And this called .php file creates a parameter that covers some value, and I want to receive it without going to this called page.

Is it possible?
If it, how can I have this parameter?

Posted: Tue Jul 05, 2005 10:53 am
by pickle
I'm a little unclear. You have two files (let's say A and B) - A has values it's pulled from MySQL. B generates some values as well. You want to be able to get variables and values from B, in A, without having to actually go to B.

Is that correct?

If so, require_once() may be what you need. That function opens and runs the required file inline.

Code: Select all

<?PHP

$first_var = 10;

?>

Code: Select all

<?PHP
$second_var = 2;

require_once('example_page.php');

echo $second_var * $first_var;//will output '20';
?>
Make sense?

Posted: Wed Jul 06, 2005 7:45 am
by mustafamisir
if there are some paramaters that have the same name, how I will call these parameters?

Posted: Wed Jul 06, 2005 10:39 am
by pickle
If there are variables with the same name in file A and and file B, then those variables will be overwritten once B is included. You'll have to rename some variables in either file A or file B.