Arama butonu
Bu konudaki kullanıcılar: 1 misafir
5
Cevap
276
Tıklama
0
Öne Çıkarma
PHP bilgi UPDATE sorunu
S
11 yıl
Yarbay
Konu Sahibi

Yeni firma eklemek istediğimde sorun yok ancak mevcut firmayı güncellemek istediğimde ilk eklenilen firmanın bilgileri ekrana geliyor ve o andan sonra bütün firmaları ilk eklenen firmaya eşitliyor, hangi firmayı güncellemek istersem isteyim hepsi birden aynı şekilde güncelleniyor.

Umarım anlatabilmişimdir. Sorun nerede sizce?

 
if($_POST['onay']){$onay = 1; }else{$onay = 0;}
$db->query ("UPDATE firma SET isim='$_POST[isim]' ,kategori='$_POST[kategori]', email='$_POST[email]', tel='$_POST[tel]', url='$_POST[url]', aciklama='$_POST[aciklama]', onay='$onay' WHERE id='$_POST[id]'");

}


<?php
if ($_GET['page'] == "new"){
?>

<form action="?req=new" method="post">
<p><label>İsim:</label><input type='text' name="isim" /></p>
<p>
<label>Kategori:</label>
<select name="kategori" size="1">
<?php

$sorgu=$db->query("SELECT * FROM kategori WHERE ust='0'");
while($bilgi = $sorgu->fetch())
{
echo "<option value='$bilgi[id]'>$bilgi[isim]</option>";

$sorgu2=$db->query("SELECT * FROM kategori WHERE ust='$bilgi[id]'");
while($bilgi2 = $sorgu2->fetch())
{
echo "<option value='$bilgi2[id]'>- $bilgi2[isim]</option>";
}
}



?>

</select>
</p>

<p><label>Email:</label><input type="text" name="email" /></p>
<p><label>Telefon:</label><input type="text" name="tel" /></p>
<p><label>Web Adres:</label><input type="text" name="url" /></p>
<p><label>Açıklama:</label><textarea name="aciklama"></textarea></p>
<p><label>Onay:</label><input type="checkbox" name="onay" /></p>
<p><label> </label><input type="submit" value="Kaydet" /></p>

</form>
<?php } elseif ($_GET['page'] == "upd"){

$sorgu = $db->query("SELECT * FROM firma WHERE id='$_GET[id]'");
$bilgi = $sorgu->fetch();

?>
<form action="?req=upd" method="post">
<p><label>İsim:</label><input type='text' name="isim" value = "<?php echo $bilgi['isim']; ?>" /></p>
<p>
<label>Kategori:</label>
<select name="kategori" size="1">



<?php

$sorgu2=$db->query("SELECT * FROM kategori WHERE ust='0'");
while($bilgi2 = $sorgu2->fetch())
{

echo "<option value='$bilgi2[id]'>$bilgi2[isim]</option>";


$sorgu3=$db->query("SELECT * FROM kategori WHERE ust='$bilgi2[id]'");
while($bilgi3 = $sorgu3->fetch())
{

echo "<option value='$bilgi3[id]'>$bilgi3[isim]</option>";
}
}

?>

</select>
</p>

<p><label>Email:</label><input type="text" name="email" value = "<?php echo $bilgi['email']; ?>" /></p>
<p><label>Telefon:</label><input type="text" name="tel" value = "<?php echo $bilgi['tel']; ?>" /></p>
<p><label>Web Adres:</label><input type="text" name="url" value = "<?php echo $bilgi['url']; ?>" /></p>
<p><label>Açıklama:</label><textarea name="aciklama"><?php echo $bilgi['aciklama']; ?></textarea></p>
<p><label>Onay:</label><input type="checkbox" name="onay" /></p>
<p><label> </label><input type="submit" value="Güncelle" /></p>

<?php
if($bilgi[onay] == 1){ $add = "checked=\"checked\"";}

?>

<input type="hidden" name="id" value = "<?php echo $bilgi['id']; ?>" />

</form>

<?php