running query through while loop returns same variables
| From: | Tom Beidler | Date: | Wed, 10 Oct 2001 19:44:23 +0000 |
| Subject: | running query through while loop returns same variables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-70729@lists.php.net to get a copy of this message | ||
I'm trying to run a query through a while loop and keep getting the same
variables. I've tried flushing out using mysql_free_result without much
success. Here's the code to give you an idea of what I'm trying to do.
while (list($key, $value) = each($year_array)) {
$js_firstgroup .= "group[$counter1][$counter2]=new Option(\"Now Select a
Make\",\" \");\n";
$make_query = "SELECT make FROM application WHERE year_in >= $value AND
year_out <= $value ORDER BY make";
$make_result = mysql_query ($make_query)
or die ("Cannot get make.");
$make_row = mysql_fetch_array ($make_result);
while ($make_row = mysql_fetch_array ($make_result)) {
$make = $make_row["make"];
$counter2++;
$counter3++;
$js_firstgroup .= "group[$counter1][$counter2]=new
Option(\"$make\",\"$counter3\");\n";
}
$js_firstgroup .= "\n";
$counter1++;
$counter2 = 0;
mysql_free_result ($make_result);
}
It apears that I keep looping through the first query array everytime.
Any help appreciated.