Temat: firma1 - usuń
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>test5</title>
</head>
<body>
<form action="" method="post">
<input type="submit" value="Usun">
<hr>
<?php
echo "<table border=1>";
echo "<tr>";
echo "<td bgcolor=yellow>`id`</td>";
echo "<td bgcolor=yellow>`imie`</td>";
echo "<td bgcolor=yellow>`nazwisko`</td>";
echo "<td bgcolor=yellow>`stanowisko`</td>";
echo "<td bgcolor=yellow>`rok`</td>";
echo "</tr>";
$con = mysqli_connect('localhost', 'root', '', 'firma1');
//INSERT
if ($_POST)
{
//usun
if (!empty($_POST['usun'])) $usun = (int)$_POST['usun']; else $usun=0;
$sql = 'DELETE FROM baza WHERE id='.$usun;
//
$wynik = mysqli_query($con, $sql);
}
//SELECT
$sql = 'SELECT * FROM baza;';
$wynik = mysqli_query($con, $sql);
//
$i=0;
while ($re=mysqli_fetch_array($wynik))
{
if ($i%2==0) $b="#e3e7e6"; else $b="#ffffff";
echo "<tr>";
// radio
$r='<input type="radio" name="usun" value="'.$re["id"].'">';
//
echo "<td bgcolor=".$b.">".$r.($re["id"])."</td>";
echo "<td bgcolor=".$b.">".($re["imie"])."</td>";
echo "<td bgcolor=".$b.">".($re["nazwisko"])."</td>";
$s="brak danych";
if ($re["stanowisko"]==1) $s="pracownik";
if ($re["stanowisko"]==2) $s="kierownik";
if ($re["stanowisko"]==1000) $s="sef";
echo "<td bgcolor=".$b.">".$s."</td>";
echo "<td bgcolor=".$b.">".($re["rok"])."</td>";
echo "</tr>";
$i++;
}
echo "</table>";
mysqli_close($con);
?>
<hr>
<input type="submit" value="Usun">
</form>