• 18-05-2010, 17:33:04
    #1
    Biliyorum konu başlığı biraz garip oldu.. Şöyle anlatayım ;

    Bu koddaki veri boş ise "Kayıtlı Haber Yok" demesini istiyorum if döngüsü ile yapmaya calıstım ama olmadı yapabilecek olan arkadaş var mı?

    <?php
      
      include ('config.php');
      $veri = odbc_exec($conn,"select TOP 5 * from _ARTICLES ORDER BY id DESC");
      	while (odbc_fetch_row($veri)) {
    
    $id         = odbc_result($veri, 1);
    $title      = odbc_result($veri, 2);
    $articles   = odbc_result($veri, 3);
    $date       = odbc_result($veri, 4);
    $views      = odbc_result($veri, 5);
    $type       = odbc_result($veri, 6);
    
    if ($type == '0') {
    $tur = 'Genel';		
    }
    elseif ($type == '1') {
    $tur = 'Oyun Haberi';		
    }
    elseif ($type == '2') {
    $tur = 'Web Haberi';		
    }
    elseif ($type == '3') {
    $tur = 'Sunucu Haberi';		
    }
    
    echo'<p>
        <ul>
            <li><a href="index.php?sayfa=articles&id='.$id.'">'.$title.'</a> - <font color="#ffcc00">'.$tur.'</font> - '.$date.'</li>
        </ul>
        </p>';
    
    }
    ?>
  • 18-05-2010, 17:40:57
    #2
    Mantık olarak mysqlde tablonun eleman sayısını bul count ile eğer 0 ise boş, değilse işlemler..
  • 18-05-2010, 17:41:03
    #3
    <?php
      
      include ('config.php');
      $veri = odbc_exec($conn,"select TOP 5 * from _ARTICLES ORDER BY id DESC");
    if(odbc_num_rows($veri)=="0"){
    echo "tablo boş";
    }
    else {
      	while (odbc_fetch_row($veri)) {
    
    $id         = odbc_result($veri, 1);
    $title      = odbc_result($veri, 2);
    $articles   = odbc_result($veri, 3);
    $date       = odbc_result($veri, 4);
    $views      = odbc_result($veri, 5);
    $type       = odbc_result($veri, 6);
    
    if ($type == '0') {
    $tur = 'Genel';		
    }
    elseif ($type == '1') {
    $tur = 'Oyun Haberi';		
    }
    elseif ($type == '2') {
    $tur = 'Web Haberi';		
    }
    elseif ($type == '3') {
    $tur = 'Sunucu Haberi';		
    }
    
    echo'<p>
        <ul>
            <li><a href="index.php?sayfa=articles&id='.$id.'">'.$title.'</a> - <font color="#ffcc00">'.$tur.'</font> - '.$date.'</li>
        </ul>
        </p>';
    
    }
    }
    
    ?>
    Yanlış anlamadıysam sorunu, bu işini görebilir...
  • 18-05-2010, 17:42:33
    #4
    Teşekkürler + rep
  • 20-05-2010, 18:43:58
    #5
    Teşekkürler