So im kinda trying to delete row from my mysql database using checkboxes. Here is my code. Would be glad if someone could write me down simple delete code. Tryed many but failed, stuck for hours with this :(
<html>
<head>
<title>Admin, User</title>
</head>
<body>
<?php include 'connect.php';?>
<?php include 'functions.php';?>
<?php include 'title_bar.php';?>
<h3>Sukurti Nauja uzduoti: </h3>
<form method='post'>
<?php
if(isset($_POST['submit2']))
{
$pav = $_POST['pav'];
$uzduotis = $_POST['uzduotis'];
if(empty($pav) or empty($uzduotis)){
echo "<p>Privalomi visi langai!</p>";
}
else {
$sql = ("INSERT INTO uzduotys VALUES ('','$pav','$uzduotis')");
}
if($database->query($sql) == TRUE)
{
header('location:kurtisalinti.php');
}
else {
echo "<p>Klaida!</p>";
}
}
?>
<p>Uzduoties pavadinimas:
<p><input type='text' name='pav' />
<p>Uzduotis:
<p><textarea name='uzduotis'></textarea>
<p><input type='submit' name='submit2' value='Sukurti Uzduoti' />
</form>
</p></p></p></p>
</form>
<h3>Pasalinti pasirinkta uzduoti is uzduociu saraso: </h3>
<?php
$query = mysqli_query($database,"SELECT uzid,pav,uzduotis FROM uzduotys");
$count=mysqli_num_rows($query);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="form1" method="post" action="">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>id</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Pavadinimas</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Aprasymas</strong></td>
</tr>
<?php
while($rows = mysqli_fetch_array($query)){
?>
<tr>
<td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" value="<?php echo $row['uzid']; ?>"></td>
<td bgcolor="#FFFFFF"><?php echo $rows['uzid']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['pav']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['uzduotis']; ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Istrinti Uzduotis"></td>
</tr>
<?php
?>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>