problem with mysql_fetch_array
| From: | Deepak Dhake | Date: | Wed, 11 Aug 2004 21:13:49 +0000 |
| Subject: | problem with mysql_fetch_array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-193505@lists.php.net to get a copy of this message | ||
i am trying to print some values from a table with using mysql_fetch_array in a loop but not able to get correct values.
it works fine for the loop i=0, prints all desired values but when it bocomes i=1 and starts the loop again the result values gets reset and prints the same old values.
for example:
outout of the query is
result 1
result 2
result 3
result 4
result 5
result 6
result 7
result 8
result 9
result 10
result 11
result 12
:when i=0, it runs through the loop and prints
result 1
result 2
result 3
result 4
result 5
result 6
:which is perfect.
:but when i=1, it prints the same values,
result 1
result 2
result 3
result 4
result 5
result 6
why is that so? can anyone help me? thanks in advance.
$query4 = mysql_query("SELECT result FROM TBL_result WHERE survey_no=2";
for($i=0; $i < 2; ++$i) //surveys{
for($j=0; $j < 2; ++$j) //questions
{ for ($k=0; $k < 3; ++$k) //sub-quesions
{
$row2 = mysql_fetch_array($query4);
//Printing all result values one by one
}
}
}