The code is :
<?php
function confirmadelprod($idp)
{ global $link;
global $op;
global $delprod;
global $idprodus;
global $idp;
$sql = "SELECT a.idprodus, a.denprod, a.um, b.dencateg
FROM produse a INNER JOIN categorii b
ON a.idcateg= b.idcateg
ORDER BY a.denprod DESC
";
$result = mysqli_query($link,$sql);
$eroare = mysqli_error($link);
if ($eroare) echo $eroare;
while($row = mysqli_fetch_array($result))
{
$idprodus = $row["idprodus"];
$denprod = $row["denprod"];
$um = $row["um"];
$dencateg = $row["dencateg"];
//butoane adauga si sterge
$linkmodi = "<a href=\"admin.php?idprodus=$idprodus&op=modiprod \"> <img src='edit.png'class='butoneditdel'/ onclick='confirmsterge()'> </a>";
$linkdel = "<a href=\"admin.php?idprodus=$idprodus&op=delprod \"> <img src='del.png'class='butoneditdel' /> </a>";
//butoane adauga si sterge END
//echo "$linkmodi | $linkdel : $idprodus | $denprod | $um | $dencateg <br />";
}
echo '<p>Sunteti sigur ca vreti sa stergeti produsul?</p>';
echo "<a href=\"admin.php?idprodus=$idprodus&op=delprod \"><button>Da</button></a>";
echo "<a href=\"admin.php?idprodus=$idprodus&op=veziproduse \"><button>Nu</button></a>";
}
function delprod($idp)
{ global $sql;
global $link;
$sql="DELETE FROM `produse` WHERE `produse`.`idprodus` = $idp";
mysqli_query($link,$sql);
$eroare = mysqli_error($link);
if ($eroare) echo $eroare;
else echo"Am sters cu succes produsul cu ID: $idp !";
} ?>
So basically what I want to do is to pass from the confirmadelprod() function to delprod() function once the “Da” button is pressed .
The problem is that whatever product from the table I try to erase it always deletes the item from the bottom of the table .
This is how the table looks like:
Sorry if the post is written bad . it’s the first one I make .