0

I'm trying to add pagination to my php script, but it didn't work and always show me http error 500

And if I delete the pagination code, it doesn't show the HTTP error 500

plz help me find the solution

pagination code:

$batas = 5;
$halaman = isset($_GET['halaman'])?(int)$_GET['halaman'] : 1;
$halaman_awal = ($halaman>1) ? ($halaman * $batas) - $batas : 0;    

$previous = $halaman - 1;
$next = $halaman + 1;

$data = mysqli_query($koneksi,"select * from tbl_files");
$jumlah_data = mysqli_num_rows($data);
$total_halaman = ceil($jumlah_data / $batas);

$data_pegawai = mysqli_query($koneksi,"select * from pegawai limit $halaman_awal, $batas");

$nomor = $halaman_awal+1;

while($d = mysqli_fetch_array($data_pegawai);

html code:

<?php 

    for($x=1;$x<=$total_halaman;$x++){

?> 

        <li class="page-item"><a class="page-link" href="?halaman=<?php echo $x ?>"><?php echo $x; ?></a></li>

        <?php

    }

?>
Grokify
  • 15,092
  • 6
  • 60
  • 81
LostSky
  • 13
  • 3
  • 1
    What have you tried to debug the problem? For example, why is this question tagged with JS and CSS, but does not contain any such code? Also, be warned that your code is widely open for SQL injection. – Nico Haase Jan 28 '21 at 15:23
  • 1
    A 500 error is an indication of a syntax error or other fatal error. Always when developing code, at the top of your script `error_reporting(E_ALL); ini_set('display_errors', 1);` then update your question with the full error. And welcome to Stack Overflow – Michael Berkowski Jan 28 '21 at 15:23
  • Your code is open to sql injection.... you should fix that – Gert B. Jan 28 '21 at 15:23
  • 2
    This is missing a closing `)` and should not end with a `;` Instead it needs a `{ }` block where you utilize your fetch logic and variable `$d`. `while($d = mysqli_fetch_array($data_pegawai);` There may be additional errors. – Michael Berkowski Jan 28 '21 at 15:24
  • `@Nico Haase` i was trying to debugging this all of my day, and it didn't work – LostSky Jan 28 '21 at 15:27

0 Answers0