mysql查询上有多个循环

Probably simple but cant get my head around this simple task...

$query = "SELECT * FROM myTable WHERE this = that";
$result = mysql_query($mycon, $query);

while ($tablerow = mysql_fetch_assoc($result) {
  do this
}

Can I rerun this while loop on the same $result without rerunning the query?

i.e.:

while ($tablerow = mysql_fetch_assoc($result) {
  do something else using the same data
}

Thanks

Yes you can use the while loop again but after every while loop place this code:

mysql_data_seek($tablerow , 0);

As, this above function always resets the pointer to its starting point in loop.

Find the full code below:

$query = "SELECT * FROM myTable WHERE this = that";
$result = mysql_query($mycon, $query);

while ($tablerow = mysql_fetch_assoc($result) {
  do this
}
mysql_data_seek($tablerow , 0);

//Do something you want

//Then again

while ($tablerow = mysql_fetch_assoc($result) {
  do this
}
mysql_data_seek($tablerow , 0);

For security purpose and mysql is deprecated also, always try to use mysqli or PDO.

I hope, this may be helpful to you.

This will cause duplicate code which is a bad practice. Use the same loop.