bence 2si içinde çok gerekli değilse veritabanı kullanma.
ne kadar az sorgu o kadar iyi.
@qplot robot dediği Googlebot vs. sanırım
bide böyle dene.
döngü dışında $first değişkenini true olarak atayıp.
Döngü içerisindede if ten sonra false olarak atarsan ilk veriden sonra hep false döneceği için class="active" yazdırmayacak.
<?php
$hizmet = pre("SELECT * FROM hizmet_kat WHERE durum=?");
$hizmet->execute(["Aktif"]);
$first = true;
foreach ( $hizmet as $key => $row ) { ?>
<li>
<a
<?php
if($first){
echo 'class="active"';
$first = false;
}
?>
data-toggle="tab" href="#<?php echo seo($row["hk_adi"]) ?>" role="tab" aria-controls="<?php echo seo($row["hk_adi"]) ?>" aria-selected="true">
<?php echo $row["hk_adi"] ?>
</a>
</li>
<?php } ?>
kategorileri yazdırırken büyük ihtimal for, foreach veya while döngüsü kullanıyorsunuz diye tahmin ediyorum.
$first = true;
while ($kategori = $data->fetch(PDO::FETCH_ASSOC)) {
if($first){
$first = false;
echo "class=active";
}
}
bu şekilde yapabilirsin.
SELECT `category`.*, `mehsul`.* FROM `category` INNER JOIN `mehsul` ON `mehsul`.categ = `category`.`id` ORDER BY `id` DESC
bu kodu kullan büyük ihtimal düzelecektir.
Bu arada mysqli komutları tarihe karıştı artık PDO ya geçmende fayda var.Daha güvenli ve daha kolay bence.
http://sqlfiddle.com/#!9/50629c/4
kodlar benim değil internetten buldum.
https://codepen.io/existenzz/pen/pOxEYx
<?php
$context = stream_context_create(array('ssl' => array('header' => 'Accept: application/xml')));
$url = 'https://webservice.ilpen.com.tr/xml/xml_list_all_products';
$xml = file_get_contents($url, false, $context);
$xml = simplexml_load_string($xml);
foreach($xml->Urunler->Urun as $urun){
$id = $urun->UrunKartiID;
$UrunAdi = $urun->UrunAdi;
$UrunGrupKodu = $urun->UrunGrupKodu;
$UrunSecenek = $urun->UrunSecenek;
foreach($UrunSecenek->Secenek as $secenek){
$VaryasyonID = $secenek->VaryasyonID;
$VaryasyonDurum = $secenek->VaryasyonDurum;
}
}
?>
Altığın bir hata yoksa.$sorgu değişkenini ekrana yazdır sorguda sıkıntı varmı diye bak.
yoksa gelen değerleri ve db'den gelen sonuçları yazdır.
Site kaynağını incelersen aşağıdaki kodu göreceksin.
Yaptığı şey Jquery ile 10sn de bir yeni veri varsa onu çekmek.
setInterval(function () {
checkContent();
}, 10000);
function checkContent() {
$.post("http://www.evdeneve.gen.tr/_endpoint/defter.php?action=check", {
lastID: lastID
}, function (response) {
if (response.success == true) {
$("#npShares").prepend(response.data);
$("#npShares .segment").first().transition('flash');
$('.npDefterLogButon').popup();
lastID = response.last;
}
}, "json");
}
<script>
var lastStack = 1;
var lastID = 2713046;
$(document)
.ready(function () {
$('.ui.form').form({
keyboardShortcuts: false,
fields: {
term: ['minLength[3]', 'empty'],
content: ['minLength[20]', 'empty']
}
});
$.fn.api.settings.api = {
'save': 'http://www.evdeneve.gen.tr/_endpoint/defter.php?action=save',
'search': 'http://www.evdeneve.gen.tr/_endpoint/defter.php?action=search'
};
$('#formDefter')
.api({
action: 'save',
method: 'POST',
serializeForm: true,
successTest: function (response) {
return response.success || false;
},
onSuccess: function (response) {
//Altta mesaj göster
$('#formDefter > .message').html(response.message).removeClass("error").addClass("success").transition('show');
//Bilgi Güncelleme İsteklerime Bi tane yerleştir
$('textarea').val('');
$("#npShares").prepend(response.data);
lastID = response.last;
},
onFailure: function (response) {
//Altta mesaj göster
$('#formDefter > .message').removeClass("success").addClass("error").html(response.message);
}
});
$('#formArama')
.api({
action: 'search',
method: 'POST',
serializeForm: true,
successTest: function (response) {
return response.success || false;
},
onSuccess: function (response) {
$('#formArama > .message').removeClass("error").addClass("success").html(response.message);
$("#npShares").html(response.data);
},
onFailure: function (response) {
$('#formArama > .message').removeClass("success").addClass("error").html(response.message);
},
beforeSend: function (settings) {
if ($("#npArama").val() == '') {
return false;
}
}
});
// loadContent();
$('.npDefterLogButon').popup();
$(document).on('click', '#npLoadMore', function () {
loadContent();
});
$(document).on('click', '.npDelete', function () {
var segment = $(this).closest('.segment');
$.post("http://www.evdeneve.gen.tr/_endpoint/defter.php?action=delete", {
id: $(this).attr('data')
}, function (response) {
if (response.success == true) {
segment.transition('drop');
}
}, "json");
});
$(document).on('click', '.npDefterMenu', function () {
$("html, body").animate({scrollTop: 0}, "slow");
// $("textarea").focus();
return false;
});
setInterval(function () {
checkContent();
}, 10000);
$("#npArama").focusout(function () {
if ($(this).val() == '') {
$("#npShares").html("");
lastStack = 0;
loadContent();
}
});
$(".avatar").popup({
on: 'hover'
});
});
function loadContent() {
$("#npLoadMore").addClass('loading');
$.post("http://www.evdeneve.gen.tr/_endpoint/defter.php?action=load", {
lastStackID: lastStack
}, function (response) {
if (response.success == true) {
$("#npShares").append(response.data);
$("#npLoadMore").removeClass('loading');
$('.npDefterLogButon').popup();
if (response.last > lastID) {
lastID = response.last;
}
}
}, "json");
lastStack++;
}
function checkContent() {
$.post("http://www.evdeneve.gen.tr/_endpoint/defter.php?action=check", {
lastID: lastID
}, function (response) {
if (response.success == true) {
$("#npShares").prepend(response.data);
$("#npShares .segment").first().transition('flash');
$('.npDefterLogButon').popup();
lastID = response.last;
}
}, "json");
}
</script>
Bunun nedeni ajax ile sayfayı yenilemeden sadece <div class="content"></div> içeriğini değiştiriyor.
Bu tarz konularda bende takıntılıyım ama daha önemli sıkıntılar var bence cevabı düzenleme özelliğinin olmaması gibi :D
Apache serverda rewrite_module özelliği aktif mi?
bunla alakalı değilse .htaccess dosyası hatalı olabilir tekrar oluşturup dene.