title: Cart data not shown in html table
body: <p>I have made a simple cart in which i want to show selected items in my cart. I can select item successfully when i <code>print_r</code> my array it shows the data.Even the count of <code>session['cart']</code> increases as well. But unluckily it isn't showing data in my sidebar table. Here is my code. Any suggestions please.I am stuck with this.
  <a href="https://i.stack.imgur.com/AcWc1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AcWc1.png" alt="First entry update quantity"></a>
  <a href="https://i.stack.imgur.com/hQkKq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hQkKq.png" alt="2nd pic "></a></p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>     &lt;?php
  
          if(isset($_GET['action']) &amp;&amp; $_GET['action']=="add"){
             $id=intval($_GET['id']);
  $size = $_GET['size'];
  $color = $_GET['color'];
      //$index=$id.$color.$size;
  $sql_p="SELECT * FROM products WHERE productid={$id}";
  
  $query_p=mysqli_query($con, $sql_p);
  if(mysqli_num_rows($query_p)!=0){
      $row_p=mysqli_fetch_array($query_p);
  if(isset($_SESSION['cart'][$id])  &amp;&amp; isset($_SESSION['cart'][$id]['color']) &amp;&amp; $_SESSION['cart'][$id]['color'] == $color &amp;&amp; isset($_SESSION['cart'][$id]['size']) &amp;&amp; $_SESSION['cart'][$id]['size'] == $size)
          {
              $_SESSION['cart'][$id]['quantity']++;
             // $_SESSION['cart'][$index] = array('quantity' =&gt; $_SESSION['cart'][$id]['quantity'], 'price' =&gt; $row_p['product_price'], 'id' =&gt; $id, 'size' =&gt; $size, 'color' =&gt; $color, 'name' =&gt; $row_p['product_name']);
  
              print_r($_SESSION['cart'][$id]);
              echo "\n";
              //print_r($_SESSION['cart'][$index]);
  
              echo "&lt;script&gt;alert('".$row_p['product_name']." has been added to your cart.');&lt;/script&gt;";
  }
  else{
  
     // $_SESSION['cart'][$index]=array("quantity" =&gt; 1, "price" =&gt; $row_p['product_price'],"color"=&gt; $color,"size"=&gt; $size,"name"=&gt;$row_p['product_name']);
       $_SESSION['cart'][$row_p['productid']]=array("quantity" =&gt; 1, "price" =&gt; $row_p['product_price'],"color"=&gt; $color,"size"=&gt; $size,"name"=&gt;$row_p['product_name']);
         print_r($_SESSION['cart'][$row_p['productid']]);
      }
  }
  }
  ?&gt;
  </code></pre>
  
  <p><strong>cart table</strong></p>
  
  <pre><code>     &lt;div id="sidebar"&gt;
              &lt;h1&gt;Cart:   &lt;?php echo  count($_SESSION['cart']); ?&gt;&lt;/h1&gt;
              &lt;table border="1"&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Id&lt;/th&gt;
                      &lt;th&gt;Name&lt;/th&gt;
                      &lt;th&gt;Quantity&lt;/th&gt;
                      &lt;th&gt;color&lt;/th&gt;
                      &lt;th&gt;size&lt;/th&gt;
                      &lt;th&gt;&lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;?php
                  if(isset($_SESSION['cart'])){
  
                          $sql="Select * from products where productid IN (";
                          foreach($_SESSION['cart'] as $id =&gt; $value){
                              $sql .=$id. ",";
                          }
  
                          $sql=substr($sql,0,-1) . ") ORDER BY productid ASC";
                          $query = mysqli_query($con, $sql);
                          if(!empty($query)){
                              while($row = mysqli_fetch_array($query)){
  
                                  ?&gt;
  
  
  
  
                          &lt;tr&gt;
                              &lt;td&gt;&lt;?php echo $row['productid'] ?&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;?php echo $row['product_name']?&gt;&lt;/td&gt;
                         &lt;td&gt;&lt;?php echo $_SESSION['cart'][$row['productid']]['quantity']; ?&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;?php echo  $_SESSION['cart'][$row['productid']]['color']?&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;?php echo $_SESSION['cart'][$row['productid']]['size'] ?&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;a href="index.php?page=remove_from_cart&amp;action=remove&amp;id=&lt;?php echo $row['productid']; ?&gt;"&gt;x&lt;/a&gt; &lt;/td&gt;
                          &lt;/tr&gt;
  
                      &lt;?php
  
                      }
                      }
                      ?&gt;
  
            &lt;tr&gt;&lt;td colspan="3"&gt;&lt;a href="index.php?page=cart"&gt;Go To Cart&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;?php echo "Your Cart is Empty"; ?&gt;&lt;/td&gt;&lt;/tr&gt;
  
          &lt;/table&gt;
        &lt;/div&gt;
  </code></pre>