Fog Juice Posted February 12, 2008 Share Posted February 12, 2008 Is there a php function to end a while loop using mysql_fetch_array before it reads through all the records? while($row=mysql_fetch_array($results)) { if($a == $row['id']) { end(); ? <--- looking for something here to stop the while loop, any suggestions? } } Thanks in advance to anyone that helps! Quote Link to comment https://forums.phpfreaks.com/topic/90710-what-is-the-php-command-to-end-mysql_fetch_array-prematurely/ Share on other sites More sharing options...
effigy Posted February 12, 2008 Share Posted February 12, 2008 break. Quote Link to comment https://forums.phpfreaks.com/topic/90710-what-is-the-php-command-to-end-mysql_fetch_array-prematurely/#findComment-464953 Share on other sites More sharing options...
keeB Posted February 12, 2008 Share Posted February 12, 2008 You're looking for break, or exit; In your example above... 'SELECT * FROM SOMEWHERE where id=$a' Quote Link to comment https://forums.phpfreaks.com/topic/90710-what-is-the-php-command-to-end-mysql_fetch_array-prematurely/#findComment-464954 Share on other sites More sharing options...
Fog Juice Posted February 12, 2008 Author Share Posted February 12, 2008 You're looking for break, or exit; In your example above... 'SELECT * FROM SOMEWHERE where id=$a' yes i know, the example is just hypothetical and was only just typed up to give an example of what i'm looking for. Quote Link to comment https://forums.phpfreaks.com/topic/90710-what-is-the-php-command-to-end-mysql_fetch_array-prematurely/#findComment-464955 Share on other sites More sharing options...
Fog Juice Posted February 12, 2008 Author Share Posted February 12, 2008 thanks everyone, solved. *edit* - now only if the solved link showed up.. :S Quote Link to comment https://forums.phpfreaks.com/topic/90710-what-is-the-php-command-to-end-mysql_fetch_array-prematurely/#findComment-464956 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.