Hello, SO I am able to add one item but I would like to add more than 1 item. Can you guys help me with it?

<?php
     require "connect.php";
     $query = "SELECT `DVDID`, `NameOfTheDVD`, `Quantity`, `Price` FROM `DVD` ";
     $stmt = $dbhandle->prepare($query);
     $stmt->execute();

     $num = $stmt->rowCount();

     if($num>0){
      while ($row = $stmt->fetch(PDO::FETCH_OBJ)){
       if(!isset($_SESSION['cart'])){
        echo "<table border='3' cellpadding='10' position='relative` bottom= '450px' color = 'blue';>";//start table

        echo '<div class="DVD ID">'; 
        echo '<tr><td>DVD Id : '.$row->DVDID. '<br></td>' ;
        echo '<td>Name Of the DVD : '.$row->NameOfTheDVD.'<br></td>';
        echo '<td>Quantity :  '.$row->Quantity.'</td>';
        echo '<td>Price:  '.$row->Price.'</td></tr> ';

        $mydvd = $row->DVDID;
        $name = $row->NameOfTheDVD;
        $Quantity = $row -> Quantity;
        $Price = $row -> Price;

        echo $mydvd;
        //echo '<form method="post" action="basket.php?id='.$mydvd.'">';

        echo '<input type="hidden" name="id" value="'.$mydvd.'">';
        echo '<input type="hidden" name="item" value="'.$name.'">';
        echo '<input type="hidden" name="Quantity" value="'.$Quantity.'">';
        echo '<input type="hidden" name="Price" value="'.$Price.'">';
        echo '<input type="hidden" name="Cart" value="'.$cartItemCount.'">';
        //echo '<input type="submit" value="Add To Basket">';
        echo '<a href = "basket.php?id='.$mydvd.'&name='.$name.'&Quantity='.$Quantity.'&Cart='.$cartItemCount.'&Price='.$Price.'"> Add To Basket</a><br>';

        }

        }

        echo "</table>";
        }



        // no products in the database
        else{
          echo "No products found.";
        }



     ?>

your using PDO. right now im still studying that
Try creating a database_name basket
then validate it.

  1. ADD the item in which there is no other item inside that basket with the same id
  2. if there is an item like that you should add +1 to the same id of that item
    basically UPDATE the values
  3. remove the item means DELETE function with the id on it
  4. remove all requires a user_id in which to check the users item inside the basket

sorry cant help with PDO yet
i can just give you the algorithm(steps) on your question

Well, thanks for your effort.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.