Hi,
Having a problem with a nested loop outputting to html.
Trying to dynamically write out three textboxes onto the page, and populate them with the resultset of a simple query.
This is the query:
$sql = mysql_query("Select write_region From resume_locations Where resume_id = '$res_id'");
The three textboxes are then written out via the following:
for($n=0;$n<3;$n++) {
echo "<input type=\"text\" name=\"wlocation[]\" size=\"28\" maxlength=\"185\" style=\"font-size: 10px\"\n";
I then tried to use another loop to populate the textbox values with the results of the query. Please note, there should always be three textboxes, even if the query returns zero rows. That way the user can enter data into the textboxes.
So the next loop is:
while($wl = mysql_fetch_array($sql)){
echo "value=\"" .$wl[write_region]."\"\n";
}
Then close the textbox:
echo " /><br />\n";
}
Of course what's happening is that only the first row of data from the query is being written out, the other textboxes are empty, although in this particular query there should be 2 rows of data.
Any help would be gratefully appreciated.
Thanks!