I make an online store for PCP. When clicking on the button "add product to cart" - send a Get-request product id. The problem is that no more than one product is added to the basket (the one on which it was clicked), you click on another product - it is added, and the previous one disappears. need the help of experts in bringing the code to mind) so that the goods are added normally. Below is the code to add to the cart.
if(isset($_GET['add'])){ $_SESSION['id'] = $_GET['add']; require_once 'connection.php'; $link = mysqli_connect($host, $user, $password, $database) or die("Error!" . mysqli_error($link)); $link->set_charset("utf8"); $query = 'SELECT * FROM books WHERE id="' .$_SESSION['id']. '"'; $result = mysqli_query($link, $query) or die("Error!" . mysqli_error($link)); $row = mysqli_fetch_array($result); echo "<p>" .$row['author']. ' ' .$row['name']. ' ' .$row['price']." руб.</p>"; } else { echo "<p>В корзине - пусто</p>"; }
if(isset($_GET['num_goods'] > 1)){ //добавить х-товаров- Jean-Claude