$query = $db->prepare("select * from kategoriler where id=?"); $query->execute(array($id)); $row = $query->fetch(PDO::FETCH_ASSOC); $x = $query->rowCount();
// kategori fonksiyonu
function kategori($id=0,$string=0,$ustid=0) {
global $db;
$query = $db->prepare("select * from kategoriler where kategori_ustid=? order by kate_sira desc"); $query->execute(array($id)); $goster = $query->fetchAll(PDO::FETCH_ASSOC); $x = $query->rowCount();
if($x){
foreach($goster as $row) { echo '<option value="'.$row["id"].'"';
Bu kodlarla form güncelleme yaptığımda, güncelleme yaparken eğer resim eklemezsem resim adı veri tabanından siliniyor. Güncelleme yaparken resim eklersem sorun yok. Güncellemede resim eklemediğimde neden silinir. Eklenen resmin. resim eklemesem dahi kalmasını istiyorum. Şimdiden teşekkür ederim.
DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.
Üye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.
<?php
if(isset($_POST['yukle'])){
$dosyaadi=$_FILES['file']['name'];
$boyut=($_FILES['file']['size'])/1024;
$boyut=round($boyut);
$yol=$_FILES['file']['tmp_name'];
$tur=$_FILES['file']['type'];
if($ok){
echo '<h4 style="color:green">'.constant("CATE_EDIT_SUCC").'</h4>';
echo "<script>window.location = 'kateler.php'</script>";
}else {
echo '<h4 style="color:red">'.constant("CATE_EDIT_ERR").'</h4>';
}
if ($true=="image/jpeg" || "image/jpg" || "image/png" || "image/gif" || "image/svg") {
move_uploaded_file($yol,"../kate_gorsel/$dosyaadi");
}
}
?>
<?php
$id = $_GET["id"];
if ($id) {
if ($_POST) {
$sira = $_POST["kate_sira"];
$katadi = $_POST["katadi"];
$ustkatid = $_POST["ustkatid"];
$file = ($_FILES['file']['name']);
$yayin = $_POST["yayin"];
$update = $db->prepare("update kategoriler set
kate_sira=?,
kategori_adi=?,
kategori_ustid=?,
file=?,
yayin=?
where id=?
");
$ok = $update->execute(array($sira,$katadi,$ustkatid,$file,$yayin,$id));
if($ok){
echo '<h4 style="color:green">'.constant("CATE_EDIT_SUCC").'</h4>';
echo "<script>window.location = 'kateler.php'</script>";
}else {
echo '<h4 style="color:red">'.constant("CATE_EDIT_ERR").'</h4>';
}
}else {
$query = $db->prepare("select * from kategoriler where id=?");
$query->execute(array($id));
$row = $query->fetch(PDO::FETCH_ASSOC);
$x = $query->rowCount();
// kategori fonksiyonu
function kategori($id=0,$string=0,$ustid=0) {
global $db;
$query = $db->prepare("select * from kategoriler where kategori_ustid=? order by kate_sira desc");
$query->execute(array($id));
$goster = $query->fetchAll(PDO::FETCH_ASSOC);
$x = $query->rowCount();
if($x){
foreach($goster as $row) {
echo '<option value="'.$row["id"].'"';
echo $row["id"] == $ustid ? ' selected ' : null;
echo '>';
echo str_repeat("-",$string).$row["kategori_adi"];
kategori($row["id"],$string + 5,$ustid);
echo '</option>';
}
}else {
return false;
}
}
// fonksiyon bitis..
}}
?>
<a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=136845725&url=kateler.php" data-href="kateler.php"><? echo constant('BACK'); ?></a>
<form action="" method="post" enctype="multipart/form-data">
<table width="50%" cellpadding="5" cellspacing="5">
<tr>
<tr>
<th colspan="2" valign="top"><h3><? echo constant('CATE_EDIT'); ?></h3></th></tr>
<tr>
<td valign="top"><? echo constant('NO')?></td>
<td valign="top"><input type="text" name="kate_sira" size="5" value="<?php echo $row["kate_sira"];?>" /></td>
</tr>
<tr>
<td valign="top" width="20%"><? echo constant('CATE')?></td>
<td><input type="text" size="50" name="katadi" value="<?php echo $row["kategori_adi"];?>" /></td></tr>
<tr>
<td valign="top"><? echo constant('CATE_IMG')?></td>
<td valign="top"><br>
<?php
if ($row["file"] == '') {
echo '<img src="../../img/resimyok.jpg"/>';
} else if ($row["file"]!= '') {
echo '<img src="../kate_gorsel/'.$row["file"].'" width="100"/>';
}
?>
<br><br><input type="file" name="file" class="myButton">
</td>
</tr>
<tr>
<td valign="top"><? echo constant('CATE_PUB')?></td>
<td valign="top">
<?php
if ($row["yayin"] == 'V') {
echo constant('AVAILABLE');
} else {
echo constant('UNAVAILABLE');
}
?>
<select name="yayin">
<option></option>
<option value="V"><? echo constant('AVAILABLE')?></option>
<option value="Y"><? echo constant('UNAVAILABLE')?></option>
</select>
</td>
</tr>
<tr>
<td valign="top"><? echo constant('UP_CATE')?></td>
<td valign="top"><select name="ustkatid">
<option value="0"><? echo constant('MAIN_CATE')?></option>
<?php kategori(0,0,$row["kategori_ustid"]);?>
</select></td>
</tr>
<tr></tr>
<tr>
<td valign="top"> </td>
<td valign="top"><input type="submit" name="yukle" class="myButton" value="<? echo constant('EDIT')?>"/></td>
</tr>
</table>
</form>
Bu kodlarla form güncelleme yaptığımda, güncelleme yaparken eğer resim eklemezsem resim adı veri tabanından siliniyor. Güncelleme yaparken resim eklersem sorun yok. Güncellemede resim eklemediğimde neden silinir. Eklenen resmin. resim eklemesem dahi kalmasını istiyorum. Şimdiden teşekkür ederim.
DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.
Üye Ol Şimdi DeğilÜye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.