title: Mysql row returns last value in array, but I expect the whole row
body: <p>Here is my cart code:</p>
  
  <pre><code>function cart() {
  
      $total = 0;
      $item_quantity = 0;
      $item_name = 0;
      $item_number = 1;
      $amount = 1;
      $quantity = 1;
  
      foreach ($_SESSION as $name =&gt; $value) {
  
          if($value &gt; 0 ) {
  
              if(substr($name, 0, 8) == "product_"){
  
                  $length = strlen($name - 8);
                  $id = substr($name, 8 , $length);
  
                  $query = query("SELECT * FROM products WHERE product_id = " . escape_string($id)." ");
                  confirm($query);
  
                  $titleArr = array();
                  while($row = fetch_array($query)) {
                      $titleArr[$id] = $row['product_title'];
                      $product_name = implode(",", $titleArr);
                      $order_product = $product_name . "-". $value;
  
                      $sub = $row['product_price']*$value;
                      $item_quantity +=$value;
                      $item_number++;
                      $amount++;
                      $quantity++;
                      $id++;
                  }
                  $_SESSION['item_total'] = $total += $sub;
                  $_SESSION['item_quantity'] = $item_quantity;
                  $_SESSION['item_name'] = $order_product;
  
              }
          }
      }
  }
  </code></pre>
  
  <p>I searched online for a long time, please advise.</p>
  
  <pre><code>$_SESSION['item_name'] = $order_product;
  </code></pre>
  
  <p>It gives last value from fetch_array I want all product title on cart page.</p>