hi greetings I would like to know if someone could help me, what happens is that I am developing an online store in which after saving my shopping cart in my bd, haora was born the need to edit the data of the cart that I keep in the bd, I have been trying to draw the data from my note table with a select and empty them to a session called shopping_cart for its subsequent edition of the list of products and thus update the bd with the new products that the user wants. this is my code I do not load the products to the shopping cart, in which I am wrong greetings I hope you fast, I receive the code of the quote to which this product note is linked by the method get,
<?php
include '../conexion/conexion.php';
$cod_coti=htmlentities($_GET['cod_coti']);
if(isset($_SESSION["shopping_cart"]))
{
$item_array_id = array_column($_SESSION["shopping_cart"], "item_id");
// if(!in_array($_GET["cod_coti"], $item_array_id))
// {
$sel=$con->prepare("SELECT*FROM nota WHERE cod_cotizacion1 =? ");
$sel->bind_param('s',$cod_coti);
$sel->execute();
$res=$sel->get_result();
$row=mysqli_num_rows($res);
while($f=$res->fetch_assoc()){
$count = count($_SESSION["shopping_cart"]);
$item_array = array(
'item_id' => $f['modelo2'],
'item_name' => $f['nombrepro'],
'item_price' => $f['precio'],
'item_quantity' => $f['cantidad']
);
// $_SESSION["shopping_cart"][$count] = $item_array;
array_push($_SESSION['shopping_cart'], $item_array);
}
// asigno valor a variable code= a cero para evitar que recarge la pagina con el valor
// }
}
?>
Note the file: include '../conexion/conexion.php'; already contains the sessionstart this is the code in the connection file:
<?php
@session_start();// aqui en sesion start se guardaran todas la variables
$con= new mysqli('localhost','root','123','empresa');
?>