Reputation: 67
I have an HTML form, which returns a list of teams that are held within a database, the list of teams returns fine, however I want to print the selected team on the screen and my code seems to be returning the value 'teams' instead of the actual team being selected. I guess this is something to do with the way the options values re being populated and could use some assistance!
Here is the code:
Team:
<select name ="team">
<?php for($j =0 ; $j <$rows ; $j++) {
$row = mysql_fetch_row($result);
?>
<option value ="teams"><?php echo $row[0];}?></option>
</select>
<input type="submit" value="Add Player" />
</form>
<?php
This is what I am using to echo the team select:
$team = get_post('team');
echo $team;
Upvotes: 0
Views: 108
Reputation: 304
<select name ="team">
<?php
for($j =0 ; $j <$rows ; $j++) {
$row = mysql_fetch_row($result);
?>
<option value ="<?php echo $row[0];?>"><?php echo $row[0];?></option>
<?php
}
?>
</select>
<input type="submit" value="Add Player" />
</form>
$row[0] contains the value that will be sent
Upvotes: 1