<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>firma1</title>
</head>
<body bgcolor="#eeeeee">
<?php
if (isset($_POST["i"])) $i=(int)$_POST["i"]; else $i=0;
if (isset($_POST["t"])) $t=$_POST["t"]; else $t="";
?>
<form action="" method="post">
ID:
<input type="number" name="i" value="<?php echo $i; ?>" style="width:50px;">
Imie:
<input type="text" name="t" value="<?php echo $t; ?>">
<input type="submit" value="Zmień">
</form>
<hr>
<?php
if ($_POST)
{
$co=mysqli_connect("localhost", "root", "", "firma1");
// Zmień rekord
$sql = 'UPDATE baza SET imie="'.$t.'" WHERE id='.$i;
$wynik = mysqli_query($co, $sql);
if (mysqli_affected_rows($co))
echo '<p>Zmieniono rekord</p>';
else
echo '<p>Nie mogę zmienić rekordu</p>';
mysqli_close($co);
}
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>";
$co=mysqli_connect("localhost", "root", "", "firma1");
$qu=mysqli_query($co, "SELECT * FROM baza;");
while ($re=mysqli_fetch_array($qu))
{
echo "<tr>";
echo "<td>".($re["id"])."</td>";
echo "<td>".($re["imie"])."</td>";
echo "<td>".($re["nazwisko"])."</td>";
echo "<td>".($re["stanowisko"])."</td>";
echo "<td>".($re["rok"])."</td>";
echo "</tr>";
}
mysqli_close($co);
echo "</table>";
?>