title: jQuery onclick delete row from mysql table
body: <p>I wrote a function to delete an item from cart; the success message flash, but the item is not getting deleted.  There's no error message being flagged in the console. However I think my query is wrong. </p>
  
  <p><strong>cart.php</strong></p>
  
  <pre><code>         &lt;form id='updateCartForm' action="update_cart.php" method="get"&gt;
   &lt;input name="cart_item_id" type = "hidden"  id ="cart_item_id" value='&lt;?=$product['id'];?&gt;'&gt;
   &lt;/form&gt;
    &lt;button class="btn btn-warning" onclick='update_cart(); return false;'&gt;&amp;times&lt;/button&gt;
  </code></pre>
  
  <p><strong>footer.php</strong></p>
  
  <pre><code>function update_cart(){
      jQuery('#updateCartErrors').html("");
      var cart_item_id = jQuery('#cart_item_id').val();
      var error = ' ';
  var data = jQuery('#updateCartForm').serialize();
  
      jQuery.ajax({
      url : '/ecommerce/customer/parsers/update_cart.php ',
      method: 'get',
      data :  data, 
      success : function (){
          location.reload();
      },
      error : function(){alert("Something went wrong");}
  });
  }
  </code></pre>
  
  <p><strong>update_cart.php</strong>   </p>
  
  <pre><code>&lt;?php
  ob_start();
  require_once $_SERVER['DOCUMENT_ROOT'].'/ecommerce/core/init.php'; 
  
  $cart_item_id = $_GET['cart_item_id'];
  $sql = "DELETE FROM cart WHERE id = $cart_item_id" ;
  
  
  //flash success message
  $domain =($_SERVER['HTTP_HOST'] != 'localhost')?'.'.$_SERVER['HTTP_HOST']:false;
  $_SESSION['success_flash'] = $product['prod_name']. ' was deleted from your cart.'; 
  </code></pre>