0

Simple view built with PHP. I am trying to populate <option> tags with an inner loop. The form loads, but only the option already selected for the player is viewable. The others are never shown. I confirm with a print_r that $query_awards is just fine and populated:

<?php
//print_r($query_players);
print_r($query_awards);
foreach ($query_players as $row):
    echo "<form method=POST action=player_update><table><tr> <input type=hidden name=player_id value=".$row->id.">";
    echo "<td><input type=text name=first_name value=".$row->first_name."></td>";
    echo "<td><input type=text name=last_name value=".$row->last_name."></td>"; 
    echo "<td><input type=text name=school_name value='".$row->school_name."'></td>";
    echo "<td><select name=\"award_id\"><option selected value=".$row->award_id.">".$row->award_name."</option>";
    foreach ($query_awards as $award_row): // <-- Broken?
      "<option value=".$award_row->id.">".$award_row->name."</option></select></td>";
    endforeach;
    echo "<td><input type=submit name=submit value=Update></td>";

    echo "</tr></table></form>";
endforeach;
?>

The bothersome part is that the </select> from the inner loop is showing up.

1 Answer 1

3

You forgot the echo in the beginning of the line

"<option value=".$award_row->id.">".$award_row->name."</option></select></td>";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.