Notice: Undefined offset: 0 in /Applications/MAMP/htdocs/Homocerveserus/functions/checkout.php on line 14
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /Applications/MAMP/htdocs/Homocerveserus/functions/checkout.php on line 16
Notice: Undefined offset: 1 in /Applications/MAMP/htdocs/Homocerveserus/functions/checkout.php on line 14
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /Applications/MAMP/htdocs/Homocerveserus/functions/checkout.php on line 16
this after using this in a loop
if(isset($_GET['a'])){
unset($_SESSION['producto'][$_GET['a']]);
$_SESSION["producto"] = array_values($_SESSION["producto"]);
unset($_SESSION['cantidad'][$_GET['a']]);
$_SESSION["cantidad"] = array_values($_SESSION["cantidad"]);
}
the complete code is
<?php
session_start();
if (isset($_GET['c'])){
$_SESSION['cantidad'][$_SESSION['contador']] = $_GET['c'];
}
include '../conexion/server.php';
$suma = 0;
for ($i=0; $i < $_SESSION['contador']; ++$i){
//echo "producto:".$_SESSION['producto'][$i]."-".$_GET['c'][$i]."<br>";
$query = mysqli_query($conect,'SELECT * FROM Productos WHERE id='.$_SESSION['producto'][$i].'');
while ($fila = mysqli_fetch_array($query)) {
$cab = $_SESSION['cantidad'][$i+1];
$total = $fila['Precio']*$cab;
echo '<tr>';
echo '<td>'.$fila['Nombre'].'</td>';
echo'<td></td>';
echo '<center><td>';
echo '<center><input type=number name=ja class="las ma"
value='.$cab.'></center>';
echo '</td></center>';
echo '<td>$'.$fila['Precio'].'</td>';
echo '<td></td>';
echo '<td>$'.number_format($total,2).'</td>';
echo '<td>';
echo '<input type=hidden value='.$_SESSION['contador'].'
class=jk>';
echo '<a href=functions/checkout.php?a='.$i.'>Borrar</a>';
echo '</td>';
echo '</tr>';
$suma += $total;
}
if(isset($_GET['a'])){
unset($_SESSION['producto'][$_GET['a']]);
$_SESSION["producto"] = array_values($_SESSION["producto"]);
unset($_SESSION['cantidad'][$_GET['a']]);
$_SESSION["cantidad"] = array_values($_SESSION["cantidad"]);
}
}
echo '<tr><th colspan="5">Total</th><th colspan="2">$'.number_format($suma,2).'</th></tr>';
mysqli_close($conect);
?>