Temat: mysqli_connect inster delete
<body bgcolor="silver">
<form method="post">
Podaj imie: <input type="text" name="imie">
Usun: <input type="number" name="usun">
<input type="submit" value="Dodaj">
</form>
<hr>
<?php
$con = mysqli_connect('localhost', 'root', '', 'firma1');
if ($_POST)
{
//dodaj
if (!empty($_POST['imie'])) $imie = $_POST['imie']; else $imie="";
$sql = "INSERT INTO baza VALUES (NULL, '".$imie."', '2', '3', '4');";
$wynik = mysqli_query($con, $sql);
//usun
if (!empty($_POST['usun'])) $usun = (int)$_POST['usun']; else $usun=0;
$sql = 'DELETE FROM baza WHERE id='.$usun;
$wynik = mysqli_query($con, $sql);
}
mysqli_close($con);
$con = mysqli_connect('localhost', 'root', '', 'firma1');
$sql = 'SELECT * FROM baza;';
$wynik = mysqli_query($con, $sql);
//
while ($wiersz = mysqli_fetch_array($wynik))
{
echo $wiersz['id'].' - '.$wiersz['imie'].' - '.$wiersz['nazwisko'].'<br>';
}
mysqli_close($con);
?>