i have php script that pulls data 3 tables , math not best looking works issue have on 35,000 times need done of able few 100 in 50 minutes here code
<?php //my sql ini_set('max_execution_time', 3000); $servername = "x.x.x.x"; $username = "uaer"; $password = "psass"; $dbname = "evemur"; $avgvar = "10"; //mysql con string $con = mysqli_connect("127.0.0.1", "root", "", "evemur"); $sql = "select * `industryactivityproducts` `activityid` = 1 order `typeid` asc "; $result = mysqli_query($con, $sql) or die(mysqli_error($con)); $reret = mysqli_num_rows($result); ($x = 0; $x <= $reret -1; $x++) { $row = mysqli_fetch_row($result); $blue = $row[0]; $ter = $row[1]; $fitem = $row[2]; $dqut = $row[3]; $cost = 0; $sql2 = "select * `industryactivitymaterials` `typeid` = $blue , `activityid` = 1 order `typeid` asc "; $result2 = mysqli_query($con, $sql2) or die(mysqli_error($con)); // retures mat make , qut $reret4 = mysqli_num_rows($result2); ($s = 0; $s <= $reret4 -1; $s++) { $reret2 = mysqli_fetch_row($result2); $mat = $reret2[2]; $matq = $reret2[3]; ($f = 0; $f <= 1 -1; $f++) { $avgprice = 0; $sql3 = "select * `items` `buy` not '1' , `volume entered` >1 , `type` = $mat order `price` asc "; $result3 = mysqli_query($con, $sql3) or die(mysqli_error($con)); ($d = 0; $d <= $avgvar; $d++) { $row3 = mysqli_fetch_row($result3); $avgprice = $avgprice + $row3[2]; } $avgprice = $avgprice / ($avgvar + 1); $cost = $cost + ($avgprice * $matq); $avgprice = number_format($avgprice, 2, '.', ','); echo $avgprice . " ".$mat. "<br>"; } } $sql5 = "select * `items` `buy` not '' , `type` = $fitem order `items`.`price` desc "; $result5 = mysqli_query($con, $sql5) or die(mysqli_error($con)); $row5 = mysqli_fetch_row($result5); $pfit = $row5[2] * $dqut; $pfit1 = $pfit - $cost; $cost = number_format($cost, 2, '.', ','); $pfit1 = number_format($pfit1, 2, '.', ','); echo $fitem." cost:" . $cost ." ". "you make " . $pfit1 ; } ?>
you should load of data tables before entering loops, rather executing mysql functions in every loop. should increase speed of script.
otherwise you're performing basic mathematical operations there's not improve in terms of speed.
Comments
Post a Comment