Resetting a while loop
<p>I have found a confusing thing in a php script I am writing to generate some javascript. Here it is below, slightly simplified.</p>

<p>The second while loop won't run unless I comment out the entire first while loop. Can anyone explain why? Many thanks.</p>

<pre><code>&lt;?php
$listid = 2; //DEMO ONLY
$result1 = mysql_query("SELECT words.wid,words.wordmd5,words.word FROM words,instances WHERE words.wid = instances.wid AND instances.lid = \"$listid\"");
$result1copy = $result1;

$count1 = 1;
while( $row = mysql_fetch_object( $result1 ) )
{
print "words_left[$count1] = \"".$row-&gt;word."\";\n";
//Increment the array counter (starts at 1)
$count1++;
}
?&gt;

//Some javascript

  &lt;?php      

  $count2 = 1;
while( $row = mysql_fetch_object( $result1copy ) )
{    
print "
    $count2 then $row-&gt;wordmd5
";    
$count2++;
}
?&gt;
</code></pre>
