v2.5.2
Giriş yap

Selected için gerekli kodu yerleştiremedim

pcmemo
572 defa görüntülendi

Alttaki kodu daha alttaki fonksiyonda xxxx yazan yere doğru şeklde yerleştirmeliyim.
Ama ilmim yetmedi. Yardımlarınızı rica ediyorum.

if ($c['CatID'] == $_GET['CatID]) { echo 'selected'}
<?php 

$kategori_sorgu=$db->prepare("SELECT * from tbl_kategoriler where CatID=:id");
$kategori_sorgu->execute(array( 'id' => $_GET['CatID'] ));
$kat=$kategori_sorgu->fetch(PDO::FETCH_ASSOC);

function CategoryDropDownEdit(&$output=null, $CatParID=0, $indent=null){
  global $db;
  $r = $db->prepare("SELECT CatID, KategoriAdiTR FROM tbl_kategoriler WHERE CatParID=:id");
  $r->execute(array(
    'id'  => $CatParID
  ));
  while($c = $r->fetch(PDO::FETCH_ASSOC)){
    $output .= '<option value=' . $c['CatID'] . 'xxxx>' . $indent . $c['KategoriAdiTR'] . "</option>";
    if($c['CatID'] != $CatParID){
      CategoryDropDownEdit($output, $c['CatID'], $indent . "&nbsp;&nbsp;&nbsp;&nbsp;");
    }
  }
  return $output;
}
 ?>
Cevap yaz
Cevaplar (4)
pcmemo
1373 gün önce

@farukdst çok teşekkür ederim. İşimi gördü. Gerçekten fonksiyon içinde kodlar beni zorluyor dğer taraflara göre.

Tekrar çok teşekkür ederim.

farukdst
1374 gün önce
$output .= '<option value='.$c['CatID'];
$output .= $c['CatID'] == $_GET['CatID'] ? ' selected' : null;
$output .= '>'.$indent.' '.$c['KategoriAdiTR'].'</option>';

php syntaxı insanı öldürüyor ya

pcmemo
1374 gün önce

@makifgokce teşekkür ederim. Böyle denediğimde dropdown menü içeriği kayboldu.

makifgokce
1374 gün önce

böyle dene

$output .= '<option value="' . $c['CatID'] . '" '. $c['CatID'] == $_GET['CatID'] ? 'selected' : '' .'>' . $indent . $c['KategoriAdiTR'] . '</option>';