after I answered I've done some more research and posted the correct version in the edit below
Because it's the way array iterators work in PHP, resetting the pointer should do the trick:
while($row=mysql_fetch_array($result))
{
//some code
}
// reset($result); - won't work with mysql_query() result
mysql_data_seek($result, 0);
while($row=mysql_fetch_array($result))
{
//some code
}
Read more on the reset() function here
EDIT: after more research I found I was wrong - use mysql_data_seek:
mysql_data_seek($result, 0);