PHP is a Request/Response based language. That means that each time you load a page, the server believes that it's serving someone new. So when you go from File1 to File2, the web server does not know that you've even been to File1 in the first place.
Well, not unless you do something about it.
There are a few ways you could overcome this:
- Using session variables
Sessions are a simple way to store data for individual users against a unique session ID. This can be used to persist state information between page requests. Session IDs are normally sent to the browser via session cookies and the ID is used to retrieve existing session data. The absence of an ID or session cookie lets PHP know to create a new session, and generate a new session ID.
You your code could work like the one below. (Note that this code is there to help explain the concept and should not be used in any real world application).
File1:
session_start();
$query = "SELECT * FROM table1 where field1 = 'abc' and feild2='xyz'";
$query1 = "SELECT * FROM table2 where field1= 'abc' and feild2='xyz'";
$query2 = "SELECT * FROM table3 where field1= 'abc' and feild2='xyz'";
$_SESSION['query'] = $query;
$_SESSION['query1'] = $query1;
$_SESSION['query2'] = $query2;
<a target="_blank" href='file2.php' >Firstquery</a>
<a target="_blank" href='file2.php' >seconquery</a>
<a target="_blank" href='file2.php' >thirdquery</a>
File2:
session_start();
echo $_SESSION['query'];
echo $_SESSION['query1'];
echo $_SESSION['query2'];
- Post values via a hidden field