Reputation: 27
I have a function that return a value by checking an exiting details in database mysql inside the function I have a while loop by an array from sql query. I want to break the while loop if its find a mach how should I do it ?
this is my code:
function chklogin()
{
$query = mysql_query("SELECT * FROM sg_loginlastauthentication WHERE uid = '$autoid' ");
$checkLogin = mysql_num_rows($query);
if ($checkLogin==0)
{
return "FALSE"; // auth fail
}
elseif ($checkLogin>1)
{
while($row = mysqli_fetch_array($query))
{
$userip = $row['uipadd'];
$userra = $row['randomnu'];
$userid = $row['uid'];
$cookieipadd = md5(md5(getclientip()));
$authdb = md5($userid + $userip + $userra);
$authusco = md5($userid + $cookieipadd + $userra);
if ($authdb==$authusco) //ok
{
return "TRUE";
}
}
}
}
does the "return true" is breaking the loop or I need to place a "break;" before/after the "return" ?
Upvotes: 0
Views: 3004
Reputation: 14895
break
after returnIf called from within a function, the return statement immediately ends execution of the current function.
Upvotes: 3