iterating a for loop
Posted: Thu Jul 01, 2004 3:42 am
hi there
i would like to know how i can break out of a 'for' loop and tell it to start again with the next iteration.
for example i am using the code below to loop through an array of results i have previously got from a table and then use the returned rows to execute a series of sql statements.
if the sql query shown returns a row then i want it to break out of the function and move on to the next iteration of the 'for' loop. If it doesn't return a row then i want it to carry on with the rest of the function contained after 'else {' and when it's completed the function then move on to the next iteration of the 'for' loop!
Thanks in advance for any help
i would like to know how i can break out of a 'for' loop and tell it to start again with the next iteration.
for example i am using the code below to loop through an array of results i have previously got from a table and then use the returned rows to execute a series of sql statements.
Code: Select all
for ($count=0; $row=mysql_fetch_array($ID_array); $count++)
{
$conn = OpenDBConnection();
$selprod = "select * from Products where ProductID = " .$rowї'ProductID']. " and Discontinued = 'False'";
$result = mysql_query ($selprod, $conn) or die(mysql_error());
$row_result = mysql_num_rows ($result);
CloseDBConnection($conn);
if ($row_result >= 1)
{ //code in here where i want it to break out of function and loop on to the next iteration }
else {Thanks in advance for any help