Hello Again,
So:
- I've created a form which contains 7 pulldown menus each consisting of a roster of names.
- Each of these 7 pulldowns is identical, and is created by querying the database for a list of names meeting a specific criteria, and looping through them- adding each one as an option in the form pulldown.
Simple enough.
I have a for loop that controls the 7 passes required to create these 7 pulldowns. My original plan was to query the database once, and then walk through the list in each of the 7 iterations of the loop. However I couldn't seem to figure out how to reset the pointer back to the head of the results without redoing the query.
I would assume that at the end of each loop there would be a command I could send that would reset the results back to the top row so I could walk through and extract each of them again.
For the sake of completeness, here's my code that works currently, but is less than elegant. I'd like to move the query outside the loop and just reuse the $resultLineup1 material over and over without having to re query each time:
for ($i=1;$i<=7;$i++)
{
echo "<select name='player$i'>\n";
echo "<option value='0'></option>";
$queryLineup1 = "SELECT * FROM GAME_Lineup, LEAGUE_Roster
WHERE GAME_Lineup.Game_Date = '$today'
AND GAME_Lineup.Team_ID = '$Team_1'
AND GAME_Lineup.Player_Eligible = '1'
AND GAME_Lineup.Player_ID = LEAGUE_Roster.Player_ID
ORDER BY Player_FirstNm";
$resultLineup1 = mysqli_query($cxn,$queryLineup1)
or die ("Couldn't execute queryLineup1.");
while ($row = mysqli_fetch_assoc($resultLineup1))
{
extract($row);
echo "<option value='$Player_ID'>$Player_FirstNm $Player_LastNm</option>";
}
echo "</select>\n";
echo "<BR>";
}