Hi, I am using creating a drop down menu populated by a call to a
postgresql
database. The drop down menu is populated correctly (or appears to
be) and then upon selecting an item in the menu it is supposed to pass
the argument indicated by the menu selection to another php file which
uses that argument to make a further (refined) search on the same
database.
But upon calling the 2nd php file when I try to use the argument
passed it appears to have no value, for example echo $argument; does
not yield the value passed.
I have included both php files below. Any help would be greatly
appreciated.
1st file:
--------------------------
<html>
<body>
<?php
$connection = pg_connect("dbname=hockey1 user=rhaynes host=emma");
if (!$connection) {
print("Connection Failed.");
exit;
}
$query = "select distinct year from tradelist order by year";
$myresult = pg_exec($connection,$query);
$num_rows = pg_numrows($myresult);
if ($num_rows == 0) {
print("No records exist");
}
else {
print("<FORM METHOD=GET
ACTION=\"http://emma/rhaynes/hockey_table4.php\">");
print("Choose a year from which to search ...<br><br>");
print("<select NAME=\"year_to_search\">");
while ($row = pg_fetch_array($myresult))
{
$id = $row["year"];
print("<option VALUE = \"$id\"> $id");
}
}
print("</select>");
print("<input TYPE=\"SUBMIT\" VALUE=\"VIEW SETS\>");
print("<input TYPE=\"RESET\" VALUE=\"RESET\">");
print("</form>");
?>
</body>
</html>
------------------------
2nd file:
---------------------------------------------
<html>
<body>
<?php
echo $year_to_search;
$connection = pg_connect("dbname=hockey1 user=rhaynes host=emma");
if (!$connection) {
print("Connection Failed.");
exit;
}
$query = "select * from tradelist where year ~* '$year_to_search'";
echo $query;
$myresult = pg_exec($connection,$query);
print("
<table border=10>
<tr>
<td> Year </td> <th colspan = 2>Card Description </th>
<td>#</td> <td>Name </td>
<td> Condition </td> <td> Quantity </td> <td> Book Value </td>
</tr>");
for ($lt = 0; $lt < pg_numrows($myresult); $lt++) {
$year = pg_result($myresult, $lt,0);
$manu = pg_result($myresult,$lt,1);
$set = pg_result($myresult,$lt,2);
$card_number = pg_result($myresult,$lt,3);
$player = pg_result($myresult,$lt,4);
$condition = pg_result($myresult,$lt,5);
$quantity = pg_result($myresult,$lt,6);
$value = pg_result($myresult,$lt,7);
print("
<tr>
<td>$year</td> <td>$manu</td> <td>$set</td> <td>$card_number</td>
<td>$player</td> <td> $condition </td> <td> $quantity </td>
<td>$value</td>
</tr>
");
}
print("</table>");
?>
<a href ="http://emma/rhaynes/hockey_table4.php">Search Again</a>
</body>
</html>