'.$category_edit == $id[$j] ? 'selected' : '' .' bölümünü kaldırınca sorunsuz listelenmektedir.
<?php
/* ---------------------------------------------------- */
$sth = $baglanti->prepare("SELECT * FROM category");
$sth->execute();
$result = $sth->fetchAll(PDO::FETCH_ASSOC);
/* ---------------------------------------------------- */
$sorgu = $baglanti->prepare("SELECT COUNT(*) FROM category");
$sorgu->execute();
$category_num = $sorgu->fetchColumn(); /* KAYIT SAYISI */
if ($category_num > 0) {
for ($j=0; $j <$category_num ; $j++) {
$id[$j] = $result[$j]['id'];
$category_name[$j] = $result[$j]['category_name'];
}
}
?>
<label>Kategori Seçiniz</label>
<select class="form-control" name="category_edit" >
<?php
for ($j=0; $j < $category_num ; $j++) {
echo '
<option value="'.$id[$j].'" '.$category_edit == $id[$j] ? 'selected' : '' .' >'.$category_name[$j].'</option>
';
}
?>
</select>
<?php
for ($j=0; $j < $category_num ; $j++) {
echo '
<option value="'.$id[$j].'" '.$category_edit == $id[$j] ? 'selected' : '' .' >'.$category_name[$j].'</option>
';
}
?>