jonniejoejonson Posted November 15, 2009 Share Posted November 15, 2009 while ($row=mysql_fetch_array($sql_result)) { print $row['name']; } If i want to go through the result set more than once, How can i do it?... If you try and use the above code more than once it does not work... The only way i can see is to turn the results into arrays, and then loop through the arrays... but there must be a better way... regards J. Quote Link to comment https://forums.phpfreaks.com/topic/181606-while-loop-through-more-than-once/ Share on other sites More sharing options...
Daniel0 Posted November 15, 2009 Share Posted November 15, 2009 You have two options: 1) Reset the internal cursor: mysql_data_seek 2) Copy the results to an array. You possibly also have a third option: 3) Refactor your code to do it in one run. If at all possible, use #3. Quote Link to comment https://forums.phpfreaks.com/topic/181606-while-loop-through-more-than-once/#findComment-957919 Share on other sites More sharing options...
JAY6390 Posted November 15, 2009 Share Posted November 15, 2009 Like Daniel0 said you should be able to refactor your code to do this. why do you need it looping more than once? Quote Link to comment https://forums.phpfreaks.com/topic/181606-while-loop-through-more-than-once/#findComment-957934 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.