<?php 

require "../functions.php";

$maksimal_provider_per_halaman = 4;
$jumlah_provider = count($array_provider);
$jumlah_halaman = ceil($jumlah_provider / $maksimal_provider_per_halaman);

$array_prov_baru = [];

$b = 0;

for ($j = 0; $j < $jumlah_halaman; $j++) {
    $a = $maksimal_provider_per_halaman;
    while ($a > 0) {
        if ($b < $jumlah_provider) {
            $array_prov_baru[$j][] = $array_provider[$b];
        }

        $a--;
        $b++;
    }
}

?>

<?php foreach ($array_prov_baru[$_GET["Halaman"]] as $provider) : ?>
    <?php if ($_GET["Id"] == $provider["Provider"]) : ?>
        <a>
            <div class="provider_terpilih" id="provider_terpilih" onclick="pp('<?php print $provider['Provider'] ?>')">
                <img src="https://img.viva88athenae.com//<?php print $provider["Gambar"] ?>" alt="">
            </div>
        </a>
        <?php else : ?>
            <a>
                <div class="provider" onclick="pp('<?php print $provider['Provider'] ?>')">
                    <img src="https://img.viva88athenae.com//<?php print $provider["Gambar"] ?>" alt="">
                </div>
            </a>
    <?php endif; ?>
<?php endforeach; ?>