The title here is largely misleading I think, as this question seems most to do with sessions. And I should mention that I still am having trouble grasping sessions so hopefully any answer to my question assumes little understanding in this area. I have the following hyperlink within a table,
echo "<td><b>Industry - </b>". "<a href=\"http://pscdata.com/General/Industry.php?industry=".urlencode($row["Industry"])."\">{$row["Industry"]}</a>". "</td>";
What I want the file, http://pscdata.com/General/Industry.php, to do is perform a query within a table, pulling up all the entries in column 1 that have the matching variable for "Industry" in column 2. I need some help getting started, namely, how to carry over the variable $Industry to the next page. I have lots of session code already within the first file, and don't know how to structure it all coherently. I'll post the full file here, so that you can see more clearly what I'm doing.
<?php
session_start();
if (isset($_POST['company']) || isset($_GET['company'])){
$Company = (isset($_POST['company']))? $_POST['company']:$_GET['company'];
}
?>
<html>
<head>
<title> PSC Data </title>
</head>
<body>
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
<TR>
<TR>
<form action = "http://pscdata.com/General/GeneralInfo.php" method=POST>
<TD><img src="http://pscdata.com/Images/collaoration.gif"></td>
<TR>
</TABLE>
<TABLE border="0" cellpadding="0" cellspacing="0">
<TD align='left'><img src="http://pscdata.com/Images/PSC-data-ber.gif"></td>
<TD background="http://pscdata.com/Images/search-form.gif" width = 210 align = "center" valign = "middle"><input = "text" value = "" name = "Ticker" size = 4 maxlength = 12><input = "text" value = "" name = "Company" size = 12 maxlength = 35>   <input type = "submit" value = "Ticker/Name" name = "SearchButton"></td>
</form>
</TR>
</TABLE>
<br/>
<?php
if(isset($_SESSION['IDNumber']) && (!isset($_POST['Ticker']) || !isset($Company))) {
$IDNumber = $_SESSION['IDNumber'];
}
else {
$IDNumber = "";
$Ticker = $_POST['Ticker'];
$Company = $Company;
}
$db = mysql_connect('host', 'username', 'password') or die("Error - cound not connect to server");
$er = mysql_select_db('prent32_FinDat') or die("Error - cound not connect to database");
if (isset($_POST['Ticker']) || !isset($Company) && $IDNumber=="") {
$q = "SELECT * FROM General WHERE Ticker = '$Ticker' or Company = '$Company'";
$result = mysql_query($q) or die(mysql_error());
}
else if ($IDNumber!="") {
$q = "SELECT * FROM General WHERE Ticker = '$Ticker' or Company = '$Company'";
$result = mysql_query($q) or die(mysql_error());
}
$num_rows = mysql_num_rows($result);
if ($num_rows <=0)
?>
<td align="right" valign="top">
<table width="700" border="1" cellspacing="2" cellpadding="4">
<caption> <b>Summary</b> </caption>
<?php
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<tr><td colspan=3 align=center><font size=5><a href=".$row["Description"].">". $row["Company"]. "</a><b>, </b></font><font size=4><b>(</b>". $row["Ticker"]. "<b>)</b></font></td></tr>";
echo "<tr><td><b>Sector - </b>". $row["Sector"]. "</td>";
echo "<td><b>Country - </b>". $row["Country"]. "</td>";
echo "<td><b>Index - </b>". $row["Index1"]. "</td></tr>";
echo "<td><b>Industry - </b>". "<a href=\"http://pscdata.com/General/Industry.php?industry=".urlencode($row["Industry"])."\">{$row["Industry"]}</a>". "</td>";
echo "<td><b>Currency - </b>". $row["Currency"]. "</td>";
echo "<td><b>Alt. Index - </b>". $row["Index2"]. "</td></tr>";
echo "<tr><td colspan=3><b>Competitors - </b>". "<a href=\"http://pscdata.com/General/GeneralInfo.php?company=".urlencode($row["Competitor"])."\">{$row["Competitor"]}</a>". "<b>, </b>". "<a href=\"http://pscdata.com/General/GeneralInfo.php?company=".urlencode($row["Competitor2"])."\">{$row["Competitor2"]}</a>". "<b>, </b>". "<a href=\"http://pscdata.com/General/GeneralInfo.php?company=".urlencode($row["Competitor3"])."\">{$row["Competitor3"]}</a>". "<b>, </b>". "<a href=\"http://pscdata.com/General/GeneralInfo.php?company=".urlencode($row["Competitor4"])."\">{$row["Competitor4"]}</a>". "<b>, </b>". "<a href=\"http://pscdata.com/General/GeneralInfo.php?company=".urlencode($row["Competitor5"])."\">{$row["Competitor5"]}</a>". "<b>, </b>". "<a href=\"http://pscdata.com/General/GeneralInfo.php?company=".urlencode($row["Competitor6"])."\">{$row["Competitor6"]}</a>". "</td></tr>";
echo "<tr><td><b>Corporate Status - </b>". $row["CorporateStatus"]. "</td>";
echo "<td><b>Alt. Symbol - </b>". $row["Ticker2"]. "</td>";
echo "<td><b>Financial Units - </b>". $row["FinUnits"]. "</td></tr>";
$IDNumber = $row['IDNumber'];
}
if(isset($_POST['Ticker']) || !isset($Company)) {
$_SESSION['IDNumber'] = $IDNumber;
session_write_close();
}
else {
session_regenerate_id();
session_write_close();
}
$Ticker ="";
$Company ="";
?>
</body>
</html>