I have a cart in PHP and I wonder how I could look in the cart if there is a product? verify it and if there is a true throw product example: id name price 1 rock $ 10.00 US (I'm a cheapskate)
if (isset($_SESSION['cart']) && !empty($_SESSION['cart'])) {
foreach ($_SESSION['cart'] as $c) {
$query = "SELECT * FROM c_inventario WHERE id = " . $c['id'] . "";
$result = $conn->obtDatos($query);
if ($conn->filasConsultadas > 0) {
foreach ($result as $dts) {
$nombre = $dts['nombre'];//name
$precio = $dts['precio'];//price
}
}
}
}
with the previous code, I only obtain the products of the car, in case it is in the session