Advertisement
kura2yamato

lowongan (pake mysqli)

Sep 27th, 2019
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.09 KB | None | 0 0
  1. <?php
  2. include_once('koneksi.php');
  3.  
  4. include_once"config/kodeauto.php";
  5. include_once"config/fungsi_indotgl.php";
  6. $mysqli = @new mysqli($server, $user, $pass, $mysql_db);
  7.  
  8. // Works as of PHP 5.2.9 and 5.3.0.
  9. if ($mysqli->connect_error) {
  10.     die('Connect Error: ' . $mysqli->connect_error);
  11. }
  12.  
  13.  
  14. ?>
  15. <div class="content_right">
  16. <h2>&#187; Info Pekerjaan Terbaru</h2>
  17. <table border='0' width='700'>
  18.  
  19. <?php
  20. $per_laman = 7;
  21. $laman_sekarang = 1;
  22. if(isset($_GET['laman'])){
  23.     $laman_sekarang = $_GET['laman'];
  24.     $laman_sekarang = ($laman_sekarang > 1) ? $laman_sekarang : 1;
  25. }
  26.  
  27. $sql="SELECT count(*) c FROM lowongan,perusahaan ORDER BY id_lowongan DESC";
  28. if ($result = $mysqli->query($sql)) {
  29.  
  30.     /* Get field information for all columns */
  31.      $finfo = $result->fetch_object();
  32.      //echo '<pre>';var_dump($finfo);die;
  33.      $total_data = $finfo->c;
  34. }else{
  35.     printf("Errorcode: %s\n", $mysqli->error);die;
  36. }
  37.  
  38.  
  39.  
  40. //mysql_num_rows(mysql_query("SELECT * FROM lowongan,perusahaan ORDER BY id_lowongan DESC"));
  41. $total_laman = ceil($total_data/$per_laman);
  42. $awal = ($laman_sekarang - 1) * $per_laman;
  43.  
  44. //$tampil=mysql_query("SELECT * FROM lowongan,perusahaan where lowongan.id_perusahaan=perusahaan.id_perusahaan  ORDER BY id_lowongan DESC limit $per_laman OFFSET $awal");
  45.  
  46. $sql="SELECT * FROM lowongan
  47. left join perusahaan
  48. on lowongan.id_perusahaan=perusahaan.id_perusahaan  
  49. ORDER BY id_lowongan DESC
  50. limit $per_laman OFFSET $awal";
  51. if ($result = $mysqli->query($sql)) {
  52.     //ok
  53.     //echo "<div>$sql</div>";
  54. }else{
  55.     printf("Errorcode: %s\n", $mysqli->error);die;
  56. }
  57. $no=5;
  58. while ($r=$result->fetch_assoc() ){
  59.     //$r=mysql_fetch_array($tampil)){
  60.     $tgl=tgl_indo($r['tgl_lowongan']);
  61.  
  62. ?>
  63.     <tr><td>
  64.     <img src="foto_lowongan/<? echo $r['foto'];?>" width='130' height='130' />
  65.     <div class='title_perusahaan1'><b><? echo $r['nama_p'];?></b></div>
  66.     <?=  $tgl;?> - <? echo $r['alamat'];?>
  67.     <p><?=substr($r['deskripsi'],0,350);?> <a href='?page=detail_lowongan&id=<? echo$r['id_lowongan'];?>&idp=<?=$r['id_perusahaan'];?>'> Lihat Selengkapnya >> </a></p>
  68.     </td></tr>
  69. <?php
  70. }
  71. ?>
  72. </table>
  73. </div>
  74.  
  75. <?php if(isset($total_laman)) { ?>
  76.   <?php if($total_laman > 1) { ?>
  77.     <nav class="text-center">
  78.       <ul class="pagination">
  79.         <?php if($laman_sekarang > 1) {?>
  80.           <li>
  81.             <a href="index.php?laman=<?= $laman_sekarang - 1 ?>" aria-label="Sebelumnya">
  82.               <span aria-hidden="true">Sebelumnya</span>
  83.             </a>
  84.           </li>
  85.         <?php }else { ?>
  86.           <li class="disabled">
  87.           <a
  88.             <span aria-hidden="true">Sebelumnya</span>
  89.           </li>
  90.           </a>
  91.         <?php } ?>
  92.         <?php if($laman_sekarang < $total_laman) {?>
  93.           <li>
  94.             <a href="?page=lowongan&laman=<?= ++$laman_sekarang  ?>" aria-label="Selanjutnya">
  95.               <span aria-hidden="true">Selanjutnya</span>
  96.             </a>
  97.           </li>
  98.         <?php }else {?>
  99.           <li class="disabled">
  100.             <span aria-hidden="true">Selanjutnya</span>
  101.           </li>
  102.         <?php } ?>
  103.       </ul>
  104.     </nav>
  105.   <?php } ?>
  106. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement