
<?php
    if(isset($_GET['pasar'])) {
        $pasr = mysqli_real_escape_string($data, $_GET['pasar']);

        function timeindo($jamnya) {
            $hari = date("l", strtotime($jamnya));
        
            switch($hari){
                case 'Monday':
                    return 'Senin';
                break;
        
                case 'Tuesday':
                    return 'Selasa';
                break;
        
                case 'Wednesday':
                    return 'Rabu';
                break;
        
                case 'Thursday':
                    return 'Kamis';
                break;
        
                case 'Friday':
                    return 'Jumat';
                break;
        
                case 'Saturday':
                    return 'Sabtu';
                break;
        
                case 'Sunday':
                    return 'Minggu';
                break;
            }
        
        }

        echo '<h2 class="text-uppercase">Result Lengkap '.$pasr.'</h2>
        <div class="table-responsive">
        <table id="restable" class="table table-sm text-center table-light">
            <thead class="table-warning">
                <tr>
                    <td>Hari</td>
                    <td>Tanggal</td>
                    <td>Prize 1</td>
                    <td>Jam Result</td>
                </tr>
            </thead>
            <tbody class="align-middle">';
            
   $spa = "SELECT * FROM result_lotto INNER JOIN pasaran_web ON res_pasaran = nama_pasaranweb WHERE res_pasaran = '$pasr' ORDER BY res_jam DESC LIMIT 100";
   $qpa = mysqli_query($data, $spa);
   if(mysqli_num_rows($qpa) > 0) {
    while($fpa = mysqli_fetch_assoc($qpa)) {
        $angka = $fpa['res_angka'];
        $jam_undi = $fpa['jam_undipass'];
        $jm = $fpa['res_jam'];

        if($angka != 'xxxx') {
            echo '<tr>
            <td>'.timeindo($jm).'</td>
            <td>'.date("d-M-Y", strtotime($jm)).'</td>
            <td><span class="resballs">'.$angka.'</span></td>
            <td>'.$jam_undi.'</td>
            
        </tr>';
        }

    }
   }
            
            
        echo '</tbody>
        </table>
        </div>';

    } else {

        echo '<div class="row align-items-center">
        <div class="col-xl-6 text-light">
        </div>
  
        <div class="col-xl-6">
            <form >
                <select id="selectpasaran" class="form-select form-select-lg mb-3" aria-label=".form-select-lg example">
                <option value="0" selected>Pilih Pasaran</option>';
  
                    $spasran = "SELECT nama_pasaranweb FROM pasaran_web";
                    $qpasran = mysqli_query($data, $spasran);
  
                    if(mysqli_num_rows($qpasran) > 0) {
                        while($fpasran = mysqli_fetch_assoc($qpasran)) {
                            $pasarn = $fpasran['nama_pasaranweb'];
  
                            echo '<option class="pasaranv" value="'.$pasarn.'">'.$pasarn.'</option>';
  
                        }
                    }
  
            echo '</select>
            </form>
        </div>
  
    </div>';

    }

?> 
   


<div id="loading"><p>Mohon ditunggu...</p></div>
<div id="result-pasaran">
</div>

<div class="my-3">
    <?php echo ftab("data_result_text", "change_text", "data_result_text"); ?>
</div>