Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if($_POST['page'])
- {
- $page = $_POST['page'];
- $cur_page = $page;
- $page -= 1;
- $per_page = 2;
- $previous_btn = true;
- $next_btn = true;
- $first_btn = true;
- $last_btn = true;
- $start = $page * $per_page;
- include "config/koneksi.php";
- include "config/fungsi_indotgl.php";
- include "config/fungsi_combobox.php";
- include "config/library.php";
- include "config/fungsi_autolink.php";
- include "config/fungsi_badword.php";
- include "config/fungsi_kalender.php";
- ?>
- <?
- $query_pag_data =("SELECT * FROM berita WHERE id_kategori='$_POST[id]'
- ORDER BY id_berita DESC LIMIT $start, $per_page");
- $result_pag_data = mysql_query($query_pag_data);
- while ($r = mysql_fetch_array($result_pag_data)) {
- $tgl = tgl_indo($r[tanggal]);
- ?>
- <article>
- <div class="b_block medium_thumb clearfix">
- <div class="post_thumbnail">
- <div class="item">
- <div class="featured_thumb">
- <? if ($r[gambar]!=''){?>
- <a class="first_A" href="#" title="4 essential rules of effective logo design">
- <img src="<?php echo $accank ;?>/foto_berita/small_<?php echo $r['gambar'];?>" title='<?php echo $r['judul'];?>' alt='<?php echo $r['judul'];?>'><? }?>
- <span class="thumb-icon"><i class="icon-export"></i></span>
- </a>
- </div>
- </div><!-- /item -->
- </div><!-- /thumbnail -->
- <h3>
- <a href="post_single.html" title="4 essential rules of effective logo design">
- <?php echo $r['judul'];?></a></h3>
- <div class="details mb">
- <span class="s_category">
- <a rel="date" href="#"><i class="icon-calendar mi"></i><?php echo"$tgl- $r[jam] WIB";?></a>
- <a href="#" rel="author"><i class="icon-user mi"></i><?php echo"Diposting oleh : <b>$r[nama_lengkap]</b>";?></a>
- </span>
- <span class="more_meta">
- <a href="#" class="post-comments"><span><i class="icon-message mi"></i><span>0</span></span></a>
- </span>
- </div>
- <!-- /details -->
- <p>
- <?
- $isi_berita = htmlentities(strip_tags($r[isi_berita])); // membuat paragraf pada isi berita dan mengabaikan tag html
- $isi = substr($isi_berita,0,350); // ambil sebanyak 220 karakter
- $isi = substr($isi_berita,0,strrpos($isi," ")); // potong per spasi kalimat
- echo "$isi ... <a class=\"readmore\" href=$accank/berita/$r[id_berita]/$r[judul_seo].html>Selengkapnya</a>
- ";
- ?>
- </p>
- </div><!--/b block -->
- </article><? }?>
- <?
- /* --------------------------------------------- */
- $query_pag_num = "SELECT COUNT(*) AS count FROM berita";
- $result_pag_num = mysql_query($query_pag_num);
- $row = mysql_fetch_array($result_pag_num);
- $count = $row['count'];
- $no_of_paginations = ceil($count / $per_page);
- /* ---------------Calculating the starting and endign values for the loop----------------------------------- */
- if ($cur_page >= 7) {
- $start_loop = $cur_page - 3;
- if ($no_of_paginations > $cur_page + 3)
- $end_loop = $cur_page + 3;
- else if ($cur_page <= $no_of_paginations && $cur_page > $no_of_paginations - 6) {
- $start_loop = $no_of_paginations - 6;
- $end_loop = $no_of_paginations;
- } else {
- $end_loop = $no_of_paginations;
- }
- } else {
- $start_loop = 1;
- if ($no_of_paginations > 7)
- $end_loop = 7;
- else
- $end_loop = $no_of_paginations;
- }
- /* ----------------------------------------------------------------------------------------------------------- */
- $msg .= "<div class='pagination'><ul>";
- // FOR ENABLING THE FIRST BUTTON
- if ($first_btn && $cur_page > 1) {
- $msg .= "<li p='1' class='active'>First</li>";
- } else if ($first_btn) {
- $msg .= "<li p='1' class='inactive'>First</li>";
- }
- // FOR ENABLING THE PREVIOUS BUTTON
- if ($previous_btn && $cur_page > 1) {
- $pre = $cur_page - 1;
- $msg .= "<li p='$pre' class='active'>Previous</li>";
- } else if ($previous_btn) {
- $msg .= "<li class='inactive'>Previous</li>";
- }
- for ($i = $start_loop; $i <= $end_loop; $i++) {
- if ($cur_page == $i)
- $msg .= "<li p='$i' style='color:#fff;background-color:#006699;' class='active'>{$i}</li>";
- else
- $msg .= "<li p='$i' class='active'>{$i}</li>";
- }
- // TO ENABLE THE NEXT BUTTON
- if ($next_btn && $cur_page < $no_of_paginations) {
- $nex = $cur_page + 1;
- $msg .= "<li p='$nex' class='active'>Next</li>";
- } else if ($next_btn) {
- $msg .= "<li class='inactive'>Next</li>";
- }
- // TO ENABLE THE END BUTTON
- if ($last_btn && $cur_page < $no_of_paginations) {
- $msg .= "<li p='$no_of_paginations' class='active'>Last</li>";
- } else if ($last_btn) {
- $msg .= "<li p='$no_of_paginations' class='inactive'>Last</li>";
- }
- $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'/>";
- $total_string = "<span class='total' a='$no_of_paginations'>Page <b>" . $cur_page . "</b> of <b>$no_of_paginations</b></span>";
- $msg = $msg . "</ul>" . $goto . $total_string . "</div>"; // Content for pagination
- echo $msg;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement