Note that there are some explanatory texts on larger screens.

plurals
  1. POi can't remove the item from cart when click on `remove button`?
    primarykey
    data
    text
    <p>i have shopping cart page but problem is that i can't remove the item from cart when click on <code>remove button</code>?</p> <p>1) i want to remove item from shopping cart via product <code>pid</code> based?<br> 2) when i echo <code>$pid=intval($pid);</code> it is showing PID? on the shopping cart page?</p> <p><strong>Product Page</strong></p> <pre><code>session_start(); $id=$_REQUEST['id']; $_SESSION['pid1']= $_POST['ids']; //Product ID// &lt;form method="post"&gt; &lt;input type="hidden" name="ids" value="&lt;?php echo $id?&gt;" /&gt; &lt;/form&gt; &lt;input type="submit" class="button1" name="addtocart" value="Add To Cart" /&gt; &lt;/form&gt; </code></pre> <p><strong>Shopping Cart Page</strong> </p> <pre><code>session_start(); $pid=$_SESSION['pid1']; if($_REQUEST['command']=='delete' &amp;&amp; $pid&gt;0){ $pid=intval($pid); $max=count($_SESSION['product1']); for($i=0;$i&lt;$max;$i++){ if($pid==$_SESSION['product1'][$i]['pid']){ unset($_SESSION['product1'][$i]); break; } } $_SESSION['product1']=array_values($_SESSION['product1']); } &lt;form name="form1" method="post"&gt; &lt;input type="hidden" name="pid" /&gt; &lt;input type="hidden" name="command" /&gt; &lt;a href="javascript:del(&lt;?php echo $pid?&gt;)"&gt; &lt;input type="button" class="button2" value="Remove" /&gt; &lt;/a&gt; </code></pre> <p><strong>Shopping Cart Page Javascript</strong></p> <pre><code>&lt;script language="javascript"&gt; function del(pid){ if(confirm('Do you really mean to delete this item')){ document.form1.pid.value=pid; document.form1.command.value='delete'; document.form1.submit(); } } function clear_cart(){ if(confirm('This will empty your shopping cart, continue?')){ document.form1.command.value='clear'; document.form1.submit(); } } </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload