I'm trying to pass the player_id as a variable from a drop-down submit form to another page for use in a query.
Here is the code for the form:
$query = mysql_query("SELECT fname, lname, player_id FROM players ORDER by lname ASC");
?>
<form action=test.php method=POST>
<input type="hidden" name="<php echo $player_id ?>" value="<php echo $player_id ?>"> <select name=players>
<?php
while ($r = mysql_fetch_array($query))
{
$fname = $r["fname"];
$lname = $r["lname"];
$player_id = $r["player_id"];
echo "<option value=$player_id>$fname $lname</option>";
}
echo "</select>";
?>
<input type="submit" name="<php echo $player_id ?>" value="Plot Player" />
<input type="reset">
</form>
and the partial code for the output page:
$players = $_POST;
if (isset($players))
{
$SQL = "SELECT * from playerstats ps, players p WHERE ps.player_id='$players' and p.player_id=ps.player_id and ps.year=2005";
$RESULT = mysql_query($SQL);
if ($myrow=$RESULT) {
do {
$labels = $myrow["week"];
//$data2[] = (($row['pass_yd'] * 0.034) + ($row['pass_td'] * 6) + ($row['twopt'] * 2) + ($row['int'] * -2) + ($row['fmbl_lost'] * -2) + ($row['rush_yd'] * 0.067) + ($row['rush_td'] * 6));
$datawk[] = $myrow["week"];
$data[] = $myrow["pass_yd"];
$data2[] = $myrow["pass_td"];
$lastname = $myrow["lname"];
$firstname = $myrow["fname"];
$data_names[] = $myrow["lname"]."(".$myrow["player_id"].")";
}
while ($myrow=$RESULT);
}
Im trying to pass the variable for use in my graphing application. For some reason I can get it to work..See anything that may help me get it working?