$limit = 1 do{ if($limit > 5){ break; } if($checknum != 0){ $checknum = ++$checknum; }else{ $checknum = ++$serial_number; }