Merhabalar,
Form.php
<form action="guncelle.php" method="POST"> <input type='hidden' name='id[]' value='$id'> <?PHP require("baglanti.php"); $sql=mysql_query("Select * From urunler "); while($oku=mysql_fetch_array($sql)) { $id=$oku["id"]; $adet=$oku["adet"]; echo " <input type='hidden' name='id[]' size='3' value='".$id."'> <input type='text' name='adet[]' size='3' value='".$adet."'> <input type='submit' value='GÜNCELLE'>"; } ?> </form>
Guncelle.php
<?PHP include ("baglanti.php"); $id = $_POST["id"]; $adet=$_POST["adet"]; for ($i=0;$i<count($_POST["id"]);$i++) { $guncelle=mysql_query("Update urunler Set adet='$adet[$i]' Where id = $id[$i]"); } if ($guncelle=="1"){ echo "<script>alert('Adet Sayısı Güncellendi!');location.href='?form.php';</script>"; }
Formdan gelen veriler birden fazla olduğu için dizi değişkeni for döngüsüyle döndürüp toplamı kadar sorguyu yazdırıp yine hangi id ye hangi deger gireceğimizi döngü yardımıyla seçip güncelliyoruz.