Good, I need to know how to remove an element from the array of a for loop in php using the unset () worse than this is executed when clicking on a button or a tag to > if someone gives me a solution
<?php
session_start();
if(isset($_GET['p'])){
$_SESSION['producto'][$_SESSION['contador']] = $_GET['p'];
$_SESSION['contador']++;
}
if (isset($_GET['c'])){
$_SESSION['cantidad'][$_SESSION['contador']] = $_GET['c'];
}
include '../conexion/server.php';
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 '<center><td>';
echo '<center><input type=number name=ja class="la ma" value='.$cab.'></center>';
echo '</td></center>';
echo '<td>'.$total.'</td>';
echo '<td>';
echo '<form method=get>';
echo '<input type=hidden name=ya value='.$i.'>';
echo '<button type=submit name="boton_borrar">borrar</button>';
echo '</form>';
echo '</td>';
echo '</tr>';
if(isset($_GET['boton_borrar'])){
$v = $_GET['ya'];
unset($_SESSION['contador'][$v]);
}
}
}
?>
<?php
session_start();
if(isset($_GET['p'])){
$_SESSION['producto'][$_SESSION['contador']] = $_GET['p'];
$_SESSION['contador']++;
}
if (isset($_GET['c'])){
$_SESSION['cantidad'][$_SESSION['contador']] = $_GET['c'];
}
include '../conexion/server.php';