The code below produces the result below
Code:
code

$test=mysql_query(" 
select name
from myTable
limit 5
") ;

echo "start";
while( $row = mysql_fetch_array($test)  )
{
echo $row['name']."<br>";
}
echo "end";

result

start
Tom
Jane
John
Kate
Tim
end
I like to make it to escape after 3 turns.

The would-be code below doesn't work correctly, but I hope it shows what I want.

Code:
would-be code


$test=mysql_query(" 
select name
from myTable
limit 5
") ;

$i=1;
echo "start";
while( $row = mysql_fetch_array($test)  )
{
echo $row['name']."<br>";
if ($i==3)
{ escape() }

$i=$i+1;

}
echo "end";

target result

start
Tom
Jane
John
end