Advertisement
bincar

load data

Dec 16th, 2014
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.51 KB | None | 0 0
  1.  
  2.  
  3. <?php
  4. if($_POST['page'])
  5. {
  6. $page = $_POST['page'];
  7. $cur_page = $page;
  8. $page -= 1;
  9. $per_page = 2;
  10. $previous_btn = true;
  11. $next_btn = true;
  12. $first_btn = true;
  13. $last_btn = true;
  14. $start = $page * $per_page;
  15.  
  16.      include "config/koneksi.php";
  17.     include "config/fungsi_indotgl.php";
  18.     include "config/fungsi_combobox.php";
  19.     include "config/library.php";
  20.   include "config/fungsi_autolink.php";
  21.   include "config/fungsi_badword.php";
  22.   include "config/fungsi_kalender.php";
  23.  
  24.  
  25.  
  26.  
  27. ?>
  28.  
  29.  
  30. <?
  31.  
  32.  
  33.            
  34.  $query_pag_data  =("SELECT * FROM berita WHERE id_kategori='$_POST[id]'
  35.  ORDER BY id_berita DESC LIMIT $start, $per_page");
  36.            
  37.  
  38. $result_pag_data = mysql_query($query_pag_data);
  39. while ($r = mysql_fetch_array($result_pag_data)) {
  40.     $tgl = tgl_indo($r[tanggal]);
  41.    
  42.  
  43.                        
  44.                        
  45.                                 ?>
  46.                            
  47.                        
  48.                                   <article>
  49.                                 <div class="b_block medium_thumb clearfix">
  50.                                     <div class="post_thumbnail">
  51.                                         <div class="item">
  52.                                             <div class="featured_thumb">   
  53.                                             <?  if ($r[gambar]!=''){?>
  54.                                                 <a class="first_A" href="#" title="4 essential rules of effective logo design">
  55.                                         <img src="<?php echo $accank ;?>/foto_berita/small_<?php echo $r['gambar'];?>" title='<?php echo $r['judul'];?>' alt='<?php echo $r['judul'];?>'><? }?>
  56.                                                
  57.                                                     <span class="thumb-icon"><i class="icon-export"></i></span>
  58.                                                 </a>
  59.                                             </div>
  60.                                         </div><!-- /item -->
  61.                                     </div><!-- /thumbnail -->
  62.                
  63.                                     <h3>
  64.                                     <a href="post_single.html" title="4 essential rules of effective logo design">
  65.                                       <?php echo $r['judul'];?></a></h3>
  66.                                     <div class="details mb">
  67.                                         <span class="s_category">
  68.                                             <a rel="date" href="#"><i class="icon-calendar mi"></i><?php echo"$tgl- $r[jam] WIB";?></a>
  69.                                             <a href="#" rel="author"><i class="icon-user mi"></i><?php echo"Diposting oleh : <b>$r[nama_lengkap]</b>";?></a>
  70.                                            
  71.                                            
  72.                                         </span>
  73.                                         <span class="more_meta">
  74.                                             <a href="#" class="post-comments"><span><i class="icon-message mi"></i><span>0</span></span></a>
  75.                                         </span>
  76.                                     </div>
  77.                                     <!-- /details -->
  78.                
  79.                                     <p>
  80.                                     <?
  81.                                  $isi_berita = htmlentities(strip_tags($r[isi_berita])); // membuat paragraf pada isi berita dan mengabaikan tag html
  82.                                 $isi = substr($isi_berita,0,350); // ambil sebanyak 220 karakter
  83.                                 $isi = substr($isi_berita,0,strrpos($isi," ")); // potong per spasi kalimat
  84.                                 echo "$isi ... <a class=\"readmore\" href=$accank/berita/$r[id_berita]/$r[judul_seo].html>Selengkapnya</a>
  85.                                       ";
  86.          
  87.           ?>
  88.                                 </p>
  89.                                 </div><!--/b block -->
  90.                             </article><? }?>
  91. <?
  92.  
  93.  
  94.  
  95. /* --------------------------------------------- */
  96. $query_pag_num = "SELECT COUNT(*) AS count FROM berita";
  97. $result_pag_num = mysql_query($query_pag_num);
  98. $row = mysql_fetch_array($result_pag_num);
  99. $count = $row['count'];
  100. $no_of_paginations = ceil($count / $per_page);
  101.  
  102. /* ---------------Calculating the starting and endign values for the loop----------------------------------- */
  103. if ($cur_page >= 7) {
  104.     $start_loop = $cur_page - 3;
  105.     if ($no_of_paginations > $cur_page + 3)
  106.         $end_loop = $cur_page + 3;
  107.     else if ($cur_page <= $no_of_paginations && $cur_page > $no_of_paginations - 6) {
  108.         $start_loop = $no_of_paginations - 6;
  109.         $end_loop = $no_of_paginations;
  110.     } else {
  111.         $end_loop = $no_of_paginations;
  112.     }
  113. } else {
  114.     $start_loop = 1;
  115.     if ($no_of_paginations > 7)
  116.         $end_loop = 7;
  117.     else
  118.         $end_loop = $no_of_paginations;
  119. }
  120. /* ----------------------------------------------------------------------------------------------------------- */
  121. $msg .= "<div class='pagination'><ul>";
  122.  
  123. // FOR ENABLING THE FIRST BUTTON
  124.  
  125. if ($first_btn && $cur_page > 1) {
  126.     $msg .= "<li p='1' class='active'>First</li>";
  127. } else if ($first_btn) {
  128.     $msg .= "<li p='1' class='inactive'>First</li>";
  129. }
  130.  
  131. // FOR ENABLING THE PREVIOUS BUTTON
  132. if ($previous_btn && $cur_page > 1) {
  133.     $pre = $cur_page - 1;
  134.     $msg .= "<li p='$pre' class='active'>Previous</li>";
  135. } else if ($previous_btn) {
  136.     $msg .= "<li class='inactive'>Previous</li>";
  137. }
  138. for ($i = $start_loop; $i <= $end_loop; $i++) {
  139.  
  140.     if ($cur_page == $i)
  141.         $msg .= "<li p='$i' style='color:#fff;background-color:#006699;' class='active'>{$i}</li>";
  142.     else
  143.         $msg .= "<li p='$i' class='active'>{$i}</li>";
  144. }
  145.  
  146. // TO ENABLE THE NEXT BUTTON
  147. if ($next_btn && $cur_page < $no_of_paginations) {
  148.     $nex = $cur_page + 1;
  149.     $msg .= "<li p='$nex' class='active'>Next</li>";
  150. } else if ($next_btn) {
  151.     $msg .= "<li class='inactive'>Next</li>";
  152. }
  153.  
  154. // TO ENABLE THE END BUTTON
  155. if ($last_btn && $cur_page < $no_of_paginations) {
  156.     $msg .= "<li p='$no_of_paginations' class='active'>Last</li>";
  157. } else if ($last_btn) {
  158.     $msg .= "<li p='$no_of_paginations' class='inactive'>Last</li>";
  159. }
  160. $goto = "<input type='text' class='goto' size='1' style='margin-top:-1px;margin-left:60px;'/><input type='button' id='go_btn' class='go_button' value='Go'/>";
  161. $total_string = "<span class='total' a='$no_of_paginations'>Page <b>" . $cur_page . "</b> of <b>$no_of_paginations</b></span>";
  162. $msg = $msg . "</ul>" . $goto . $total_string . "</div>";  // Content for pagination
  163. echo $msg;
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement