Advertisement
Guest User

infinite loop on server.

a guest
Mar 20th, 2014
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $con = mysqli_connect('xx.xx.x.x', 'xx', 'xx', 'xx') or die();
  4. $items     = explode(',', $_SESSION['item']);
  5. $all_items = "";
  6. foreach ($items as $item) {
  7.     if ($all_items == "") {
  8.         $all_items = "'" . $item . "'";
  9.     } else {
  10.         $all_items .= ",'" . $item . "'";
  11.     }
  12. }
  13. $query5 = "select distinct store_id,rate,iso from products where iso in (" . $all_items . ")";
  14. $rslt5  = mysqli_query($con, $query5);
  15. while ($row5 = mysqli_fetch_assoc($rslt5)) {
  16.     $all5[] = $row5;
  17. }
  18. asort($all5);
  19. $all6   = array_values($all5);
  20. $counts = count($all6); //echo 'count is '.$counts.'<br/>';
  21. $k      = 0;
  22. for ($j = 0; $j < $counts;) {
  23.     $one       = $all6[$k]['store_id'];
  24.     $one_count = 0;
  25.     $one_sum   = 0;
  26.     for ($i = 0; $i < $counts; $i++) {
  27.         if ($all6[$i]['store_id'] == $one) {
  28.             $one_count++;
  29.             $one_sum = $one_sum + $all6[$i]['rate'];
  30.         }
  31.     }
  32.     $j = $j + $one_count;
  33.     echo 'store id' . $all6[$k]['store_id'];
  34.     $k = $counts - $one_count + 1;
  35.     echo '   items=' . $one_count . " & sum=" . $one_sum . '<hr/>';
  36. }
  37. echo '<pre>';
  38. print_r($all6);
  39. echo '</pre>';
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement