Database: `sklep`
https://ti.dxe.pl/files4/sklep/sklep.sql
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>sklep</title>
</head>
<body bgcolor="#eeeeee">
<?php
if (isset($_POST["p"])) $p=(int)$_POST["p"]; else $p=0;
if (isset($_POST["c"])) $c=(float)$_POST["c"]; else $c=0;
if (isset($_POST["i"])) $i=(int)$_POST["i"]; else $i=0;
?>
<form action="" method="post">
Cena netto: <input type="number" name="i" value="<?php echo $i; ?>" style="width:50px;"><br>
Ilość: <input type="number" name="c" value="<?php echo $c; ?>" style="width:50px;"><br>
<input type="submit" value="Zmień">
<hr>
<?php
if ($_POST)
{
$co=mysqli_connect("localhost", "root", "", "sklep");
// Zmień rekord
$sql = 'UPDATE cennik SET cenna_netto="'.$c.'", ilosc="'.$i.'" WHERE id='.$p;
$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 $p;
echo "<table border=1>";
echo "<tr>";
echo "<td bgcolor=yellow>`id`</td>";
echo "<td bgcolor=yellow>`zdjecie`</td>";
echo "<td bgcolor=yellow>`produkt`</td>";
echo "<td bgcolor=yellow>`opis`</td>";
echo "<td bgcolor=yellow>`cenna_netto`</td>";
echo "<td bgcolor=yellow>`cenna_brutto`</td>";
echo "<td bgcolor=yellow>`ilosc`</td>";
echo "</tr>";
$co=mysqli_connect("localhost", "root", "", "sklep");
$qu=mysqli_query($co, "SELECT * FROM cennik;");
while ($re=mysqli_fetch_array($qu))
{
echo "<tr>";
echo "<td><input type=radio name=p value=".($re["id"]).">".($re["id"])."</td>";
echo "<td><img src='".($re["zdjecie"])."'></td>";
echo "<td>".($re["produkt"])."</td>";
echo "<td>".($re["opis"])."</td>";
echo "<td>".($re["cenna_netto"])."</td>";
$cenna=(float)($re["cenna_netto"]);
echo "<td>".($cenna*1.23)."</td>";
echo "<td>".($re["ilosc"])."</td>";
echo "</tr>"."\n";
}
mysqli_close($co);
echo "</table>";
?>
</form>