This is a discussion on problem passing argument from one php page to another ... within the PHP Language forums, part of the PHP Programming Forums category; Hi, I am using creating a drop down menu populated by a call to a postgresql database. The drop down ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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> |
|
|||
|
I noticed that Message-ID:
<2cb19dd6.0406051106.3201cdc@posting.google.com> from Newbie contained the following: >echo $year_to_search; Try echo $_GET['year_to_search']; -- Geoff Berrow (put thecat out to email) It's only Usenet, no one dies. My opinions, not the committee's, mine. Simple RFDs http://www.ckdog.co.uk/rfdmaker/ |
|
|||
|
looks like this has been solved... When posting in a NG, if you can cut
the example down to a few lines to demonstrate the problem it will much easier for those of us trying to help.. it may also help you learn some valuable troubleshooting techniques that you will need if you continue in the IT business. and... no I haven't spent a lot of time answering questions here, - mostly lurking - but I have been a ng reader/poster since before it was the WWW. M. Newbie wrote: > 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. <snipped> |