title: shopping cart in session how to set values, and remove values? PHP, MySQL
body: <p>hi all sorry am new in web development<br>
  i made a website <a href="http://www.q8movies.com" rel="nofollow noreferrer">my site</a><br>
  but it is almost done but i couldn't find how to make a shopping-cart<br>
  i figured out that the best way is by doing it in session<br>
  i sow in StackOverFlow a very good example <a href="https://stackoverflow.com/questions/316222/how-can-i-use-a-database-and-php-sessions-to-store-a-users-shopping-cart"> see it </a><br>
  but what to write in a bottom to add the item, if any one has any link to something that may help me please  </p>
  
  <p>and when i used the example that i mentioned before when i press on the add-to-cart bottom<br>
  this error message present<br>
  "Notice: Use of undefined constant Basket - assumed 'Basket' in C:\wamp\www\movies\Action&amp;Adventure_n_c.php on line 35<br>
  Notice: Undefined index: Basket in C:\wamp\www\movies\Action&amp;Adventure_n_c.php on line 35</p>
  
  <p>Warning: Invalid argument supplied for foreach() in C:\wamp\www\movies\Action&amp;Adventure_n_c.php on line 35"  </p>
  
  <p>my bottom is   </p>
  
  <pre><code>&lt;?PHP    
  $onpage=$_SERVER['PHP_SELF'];
  echo "&lt;a class='art-button' href='$onpage"."?ID=$PID1'&gt;Add to Cart&lt;/a&gt;";  
  ?&gt;
  </code></pre>
  
  <p>please any idea ??  </p>
  
  <p>the code for session is this:</p>
  
  <pre><code>function AddToBasket(){
     if(is_numeric($_GET["ID"])){
      $ProductID=(int)$_GET["ID"];
      $_SESSION["Basket"][]=$ProductID;
      $sOut.=ShowBasketDetail();
      return $sOut; 
    }
  }
  </code></pre>
  
  <p>In this Shoping Basket funktion we save Product IDs in an Session array. Now here the Show Basket funktion:</p>
  
  <pre><code>function ShowBasket(){
  foreach($_SESSION[Basket] as $ProductID){
      $sql="select * from products where ProductID=$ProductID";
      $result=mysql_query($sql);
      $row=mysql_fetch_row($result);
      echo "Product: ".$row[0];
      }
  </code></pre>
  
  <p>}</p>
  
  <p>Foreach ProudctID in our Session Basket we make a SQL query to output Product Informations...</p>
  
  <p>Now last but not least a clear Basket function:</p>
  
  <pre><code>function ClearBasket(){
  unset($_SESSION[Basket]);
  }
  </code></pre>
  
  <hr>
  
  <p>thanks all for your help really thanks alot, but i found this <a href="http://www.youtube.com/watch?v=LZNRvS3FvQo&amp;feature=related" rel="nofollow noreferrer">youtube video</a> that solve my problem,  </p>
  
  <p>best regards to all of you.</p>
  
  <hr>
  
  <p>thanks all for your help really thanks alot, but i found a shoping cart that solve my problem,  </p>
  
  <pre><code>&lt;?php      
      if(isset($_GET['id']))
          $cart_id=$_GET['id'];
      else
          $cart_id=1;
  
      if(isset($_GET['action']))
          $action=$_GET['action'];
      else
          $action="none";
  
      switch($action)
      {
          case "add":
              if(isset($_SESSION['cart'][$cart_id]))
                  $_SESSION['cart'][$cart_id]++;
              else
                  $_SESSION['cart'][$cart_id]=1;
          break;
          case "remove":
              if(isset($_SESSION['cart'][$cart_id]))
              {
                  $_SESSION['cart'][$cart_id]--;
                  if($_SESSION['cart'][$cart_id]==0)
                      unset($_SESSION['cart'][$cart_id]);
              }
  
  
          break;
          case "empty":
              unset($_SESSION['cart']);
          break;
      }
          ?&gt;
  </code></pre>
  
  <p>best regards to all of you.</p>