Hi,
I'm in the process of building a fantasy football website using PHP/MySQL on Dreamweaver MX 2004.
Ideally I want a drop down menu of players for their particular area of the pitch (goalies, defenders, etc). When you have chosen the player you want, you click submit and the database is updated...you can then go back and change the player if you want to.
I've created a test form (for just the goalie). The problem is, when I submit the form to update the database, the screen refreshes and the first player in the list appears in the drop down (the database updates ok). I really want it to display the player that the user has just selected.
The piece of code that seems to relate to the submission is:
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
<body>
<form action="<?php echo $editFormAction; ?>" method="POST" name="choice" id="choice">
<p>
<input name="username" type="text" id="username" value="testUser">
</p>
<p>
<select name="choose_goalie" id="choose_goalie">
<?php
do {
?>
<option value="<?php echo $row_goalie['code']?>"><?php echo $row_goalie['surname']?></option>
<?php
} while ($row_goalie = mysql_fetch_assoc($goalie));
$rows = mysql_num_rows($goalie);
if($rows > 0) {
mysql_data_seek($goalie, 0);
$row_goalie = mysql_fetch_assoc($goalie);
}
?>
</select>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<input type="hidden" name="MM_update" value="choice">
</form>
</body>
Any help greatly appreciated.
Kind regards,
Rob
I'm in the process of building a fantasy football website using PHP/MySQL on Dreamweaver MX 2004.
Ideally I want a drop down menu of players for their particular area of the pitch (goalies, defenders, etc). When you have chosen the player you want, you click submit and the database is updated...you can then go back and change the player if you want to.
I've created a test form (for just the goalie). The problem is, when I submit the form to update the database, the screen refreshes and the first player in the list appears in the drop down (the database updates ok). I really want it to display the player that the user has just selected.
The piece of code that seems to relate to the submission is:
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
<body>
<form action="<?php echo $editFormAction; ?>" method="POST" name="choice" id="choice">
<p>
<input name="username" type="text" id="username" value="testUser">
</p>
<p>
<select name="choose_goalie" id="choose_goalie">
<?php
do {
?>
<option value="<?php echo $row_goalie['code']?>"><?php echo $row_goalie['surname']?></option>
<?php
} while ($row_goalie = mysql_fetch_assoc($goalie));
$rows = mysql_num_rows($goalie);
if($rows > 0) {
mysql_data_seek($goalie, 0);
$row_goalie = mysql_fetch_assoc($goalie);
}
?>
</select>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<input type="hidden" name="MM_update" value="choice">
</form>
</body>
Any help greatly appreciated.
Kind regards,
Rob