<?php
  function ftab($db_stat, $tname, $colname) {
    require 'data.php';

    $fdb = "SELECT ".$db_stat." FROM ".$tname." LIMIT 1";
    $qdb = mysqli_query($data, $fdb);

    if(mysqli_num_rows($qdb) > 0) {
        $fetch = mysqli_fetch_assoc($qdb);
        return html_entity_decode($fetch[$colname]);
    }


}


function fwtab($db_stat, $tname, $colname, $cond1, $cond2) {
  require 'data.php';

  $fdb = "SELECT ".$db_stat." FROM ".$tname." WHERE ".$cond1." = '".$cond2."' ";
  $qdb = mysqli_query($data, $fdb);

  if(mysqli_num_rows($qdb) > 0) {
      $fetch = mysqli_fetch_assoc($qdb);
      echo html_entity_decode($fetch[$colname]);
  }


}
  
$imgfile = 'webp'; // Img Extension For Livedraw Pages


function getSpecprediksi($pasaran) {
  require 'data.php';

  $spre = "SELECT pasaran_prediksi, tanggal_prediksi FROM prediksi_togel WHERE pasaran_prediksi = '$pasaran' ORDER BY tanggal_prediksi DESC";
  $qpre = mysqli_query($data, $spre);
  $total = '';
    if(mysqli_num_rows($qpre) > 0) {
        while($fpre = mysqli_fetch_assoc($qpre)) {
        $total .= '<div class="p-prediksi my-3">
        <a class="d-flex justify-content-between" href="?page=prediksi-togel&pasaran='.$fpre['pasaran_prediksi'].'&tanggal='.date("Y-m-d", strtotime($fpre['tanggal_prediksi'])).'">
            <span class="text-uppercase">PREDIKSI TOGEL '.$fpre['pasaran_prediksi'].' <small>('.date("d/m/Y", strtotime($fpre['tanggal_prediksi'])).')</small> </span>
            <i class="fas fa-chevron-right mt-1"></i>
        </a>
        </div>';
      }

    } else {
      $total .= 'none';
    }

    return $total;
}

function getlivePasaran($pasaran) {
  require 'data.php';
  $pas = '';
  $spas = "SELECT nama_pasaranweb FROM pasaran_web WHERE nama_pasaranweb = '$pasaran'";
        $qpas = mysqli_query($data, $spas);
            if(mysqli_num_rows($qpas) > 0) {
                while($fpas = mysqli_fetch_assoc($qpas)) {
                    $pasaran = $fpas['nama_pasaranweb'];
                    $pas .=  '<div class="d-grid my-3 position-relative">
                    <button onclick="openLivedraw(\''.$pasaran.'\')" type="button" class="btn btn-warning d-flex text-btnlivedraw align-items-center justify-content-between bg-gradient text-uppercase fw-bold">Live Draw '.$pasaran.' Pools <img src="images/link-btn.png" style="margin-top: -6px;" width="20" alt="link button"></button>
                </div>';
                }
            }else {
              $pas .= 'none';
            }

        return $pas;
}

?>