Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

for loop on huge number

PHP

$SCode=$_POST['SCode'];
$ECode=$_POST['ECode'];

for($p=$SCode;$p<$ECode;$p++)
{
    $dbResult= $dbHandle->query("
    SELECT Code
    FROM Mashaghel 
    Where Code=" . $p . "");
    if(!isset($Mashaghel[0]["Code"]) || empty($Mashaghel[0]["Code"]))
    {
        $errorCode.=$p."،";
    }
}
echo $errorCode."does not existed!";

i run this with

$_POST['SCode']='010100100101002084';
$_POST['ECode']='010100100101002087';

but this does not worked and say error Maximum execution time of 60 seconds exceeded While The difference between 010100100101002084 and 010100100101002087 only 3.

why for loop do infinite!?

please help me


1 Answers

Try this

for($p=0;$p<bcsub($ECode,$SCode);$p++)
    {
        $dbResult= $dbHandle->query("SELECT Code FROM Mashaghel
Where Code=" . bcadd($SCode,$p) . "");
        if(!isset($Mashaghel[0]["Code"]) || empty($Mashaghel[0]["Code"]))
        {
            $errorCode.=bcadd($SCode,$p)."،";
        }
    }
like image 181
Shaiful Islam Avatar answered Jul 07 '26 10:07

Shaiful Islam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!