• 11-04-2021, 22:38:43
    #1
    Merhaba, php bildirim sistemi kodluyorum. Kullanıcı indexinde nasıl kaç adet okunmamış mesajı olduğunu görebilirim? tablomun adı mesajlar sütunlar ise id,to_id,mesaj,okundu_mu,tarih eğer okundu_mu 0 ise bunu saymasını istiyorum. Yardımcı olabilir misiniz?
  • 11-04-2021, 22:41:49
    #2
    $toplammesaj = $db->select('mesajlar')->from('count(id) as total')->where('okundu_mu', 0) ->where('to_id', $userid )
    ->total();
    sorgusu ile ulaşabilirsiniz.
  • 11-04-2021, 22:43:18
    #3
    SELECT COUNT(*) as total FROM mesajlar WHERE okundu_mu = 0 AND to_id=USER_ID
  • 11-04-2021, 22:47:39
    #4
    ONURERDGN adlı üyeden alıntı: mesajı görüntüle
    $toplammesaj = $db->select('mesajlar')->from('count(id) as total')->where('okundu_mu', 0) ->where('to_id', $userid )
    ->total();
    sorgusu ile ulaşabilirsiniz.
    Decentralized adlı üyeden alıntı: mesajı görüntüle
    SELECT COUNT(*) as total FROM mesajlar WHERE okundu_mu = 0 AND to_id=USER_ID
    Teşekkürler, peki bunu nasıl ekrana yazdırabilirim şu kod içerisinde ?

    Şu tarz :

    Edit :

              <?php
                                        $db->exec("SET names utf8");
                                        $sqlQuery= "SELECT COUNT(*) as total FROM mesajlar WHERE okundu_mu = 0 AND to_id=".$id."";
                                        $statement2 = $db->prepare($sqlQuery);
                                        $statement2->execute(array(':id' => $id));
                                        while($rs2 = $statement2->fetch()){
                                            $mesajsayisi = $rs2['okundu_mu'];
    
                                        ?>
  • 11-04-2021, 22:51:43
    #5
    $mesajsayisi = $db->select('mesajlar')->from('count(id) as total')->where('okundu_mu', 0) ->where('to_id', $userid )
    ->total();



    <?phpecho$mesajsayisi; ?>
  • 11-04-2021, 22:53:20
    #6
    ONURERDGN adlı üyeden alıntı: mesajı görüntüle
    $mesajsayisi = $db->select('mesajlar')->from('count(id) as total')->where('okundu_mu', 0) ->where('to_id', $userid )
    ->total();



    <?phpecho$mesajsayisi; ?>
    Çalışmadı malesef hocam bu kod
  • 11-04-2021, 23:07:53
    #7
    ONURERDGN adlı üyeden alıntı: mesajı görüntüle
    $mesajsayisi = $db->select('mesajlar')->from('count(id) as total')->where('okundu_mu', 0) ->where('to_id', $userid )
    ->total();



    <?phpecho$mesajsayisi; ?>
    select ile from değerleri yer değişmesi gerekiyor hocam sizin kodda.

    AndMex adlı üyeden alıntı: mesajı görüntüle
    Teşekkürler, peki bunu nasıl ekrana yazdırabilirim şu kod içerisinde ?

    Şu tarz :

    Edit :

              <?php
                                        $db->exec("SET names utf8");
                                        $sqlQuery= "SELECT COUNT(*) as total FROM mesajlar WHERE okundu_mu = 0 AND to_id=".$id."";
                                        $statement2 = $db->prepare($sqlQuery);
                                        $statement2->execute(array(':id' => $id));
                                        while($rs2 = $statement2->fetch()){
                                            $mesajsayisi = $rs2['okundu_mu'];
    
                                        ?>
    $rs2['total'] işinizi görmesi lazım
  • 11-04-2021, 23:12:16
    #8
    Decentralized adlı üyeden alıntı: mesajı görüntüle
    select ile from değerleri yer değişmesi gerekiyor hocam sizin kodda.



    $rs2['total'] işinizi görmesi lazım
    Evet, şimdi oldu teşekkür ederim