title: Compare data tems in a cart funtion
body: <p>Is there a way to compare two attributes in the cart function?</p>
  
  <pre><code>   $data = array(
          'id' =&gt; $id,
          'qty' =&gt; $qty,
          'price' =&gt; $price,
          'name' =&gt; $name,
          'stock' =&gt;$quan
      ); 
  </code></pre>
  
  <p>So if I have to compare the qty and stock elements,how should I implement them at the controller?</p>
  
  <p>Sorry for the late submission. Here is the controller code:</p>
  
  <pre><code> function update_c() 
  { 
      $data = $_REQUEST;
      foreach ($this-&gt;cart-&gt;contents() as $items)
              {
                  $name = $items['name'];
                  $quantity = $items['qty'];
                  $price = $items['price'];
                  $sub = $items['subtotal'];
                  $total = $this-&gt;cart-&gt;total();
                  $id = $items['id'];     
                  $quan=$items['stock'];
                  if($items['quantity']&lt;=$items['quan'])
                      {
                          $this-&gt;data['err_message'] = 'Your cart is added!';
                         $this-&gt;cart-&gt;update($data);
                          redirect($_SERVER['HTTP_REFERER']);
                      }
                  else
                      {
                          $this-&gt;data['err_message'] = 'quantity mismatch';
                      }
  
              }             
  }
  </code></pre>