Advertisement
dotphp

optimasi query

Jan 24th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.24 KB | None | 0 0
  1. <ul class="nav">
  2.             <li><a href="beranda.php">Beranda</a></li>
  3.             <li><a href="#">Berita</a>
  4.                 <div class="berita">
  5.                 <div class="nav-berita">
  6.                 <h3>Berita Terkini</h3>
  7.                 <ul>
  8.                 <?php
  9.                 include "koneksi.php";
  10.                 $query = mysqli_query($conn,"select id_berita, judul, tgl, kategori from artikel where kategori LIKE '%berita_terkini%' order by tgl desc limit 5");
  11.                 while($result = mysqli_fetch_array($query)){
  12.                     $judul = strip_tags($result['judul']);
  13.                     $judul2 = substr($judul,0,50);
  14.                     $judul2 = substr($judul,0,strrpos($judul2," "));
  15.                 ?>
  16.                     <li><a href="#" title="<?php echo $result['judul'];?>" ><?php echo $judul2." ..";?></a><hr style="margin-top:7px; margin-bottom:7px; border-style:solid;"></li>
  17.                 <?php } ?>
  18.                 <li><a href="#"><b style="color:#286815">Selengkapnya...</b></a></li>
  19.                 </ul></div>
  20.                 <div class="nav-berita">
  21.                 <h3>Berita Dalam Negri</h3>
  22.                 <ul>
  23.                 <?php
  24.                 $query = mysqli_query($conn,"select id_berita, judul, tgl, kategori from artikel where kategori LIKE '%dalam_negeri%' order by tgl desc limit 5");
  25.                 while($result = mysqli_fetch_array($query)){
  26.                     $judul = strip_tags($result['judul']);
  27.                     $judul2 = substr($judul,0,50);
  28.                     $judul2 = substr($judul,0,strrpos($judul2," "));
  29.                     ?>
  30.                     <li><a href="#" title="<?php echo $result['judul'];?>"><?php echo $judul2."..";?></a><hr style="margin-top:7px; margin-bottom:7px; border-style:solid;"></li>
  31.                 <?php } ?>
  32.                 <li><a href="#"><b style="color:#286815">Selengkapnya...</b></a></li>
  33.                 </ul></div>
  34.                  <div class="nav-berita">
  35.                  <h3>Berita Luar Negri</h3>
  36.                  <ul>
  37.                  <?php
  38.                 $query = mysqli_query($conn,"select id_berita, judul, tgl, kategori from artikel where kategori LIKE '%luar_negeri%' order by tgl desc limit 5");
  39.                 while($result = mysqli_fetch_array($query)){
  40.                     $judul = strip_tags($result['judul']);
  41.                     $judul2 = substr($judul,0,50);
  42.                     $judul2 = substr($judul,0,strrpos($judul2," "));
  43.                     ?>
  44.                     <li><a href="#" title="<?php echo $result['judul'];?>"><?php echo $judul2."..";?></a><hr style="margin-top:7px; margin-bottom:7px; border-style:solid;"></li>
  45.                     <?php } ?>
  46.                     <li><a href="#"><b style="color:#286815">Selengkapnya...</b></a></li></ul></div>  
  47.                 </div>
  48.                 </li><!--end berita-->
  49.             <li><a href="#">Tsaqofah</a></li>
  50.             <li><a href="#">Nafsiyah</a>
  51.                 <div class="nafsiyah">
  52.                 <div class="nav-nafsiyah">
  53.                 <h3>Aqidah</h3>
  54.                 <ul>
  55.                 <?php
  56.                 $query = mysqli_query($conn,"select id_berita, judul, tgl, kategori from artikel where kategori LIKE '%aqidah%' order by tgl desc limit 5");
  57.                 while($result = mysqli_fetch_array($query)){
  58.                 $judul2 = substr($result['judul'],0,43);
  59.                 $judul2 = substr($result['judul'],0,strrpos($judul2," "));
  60.                 ?>
  61.                     <li><a href="#" title="<?php echo $result['judul'];?>"><?php echo $judul2;?></a><hr style="margin-top:7px; margin-bottom:7px; border-style:solid;"></li>
  62.                 <?php } ?>
  63.                     <li><a href="#"><b style="color:#286815">Selengkapnya...</b></a></li></ul></div>
  64.                
  65.                 <div class="nav-nafsiyah">
  66.                 <h3>Akhlak</h3>
  67.                 <ul>
  68.                 <?php
  69.                 $query = mysqli_query($conn,"select id_berita, judul, tgl, kategori from artikel where kategori LIKE '%akhlak%' order by tgl desc limit 5");
  70.                 while($result = mysqli_fetch_array($query)){
  71.                     $judul = strip_tags($result['judul']);
  72.                     $judul2 = substr($judul,0,43);
  73.                     $judul2 = substr($judul,0,strrpos($judul2," "));
  74.                     ?>
  75.                     <li><a href="#" title="<?php echo $result['judul'];?>"><?php echo $judul2." ..";?></a><hr style="margin-top:7px; margin-bottom:7px; border-style:solid;"></li>
  76.                     <?php } ?>
  77.                     <li><a href="#"><b style="color:#286815">Selengkapnya...</b></a></li></ul></div>
  78.  
  79.                 <div class="nav-nafsiyah">
  80.                 <h3>Sirah</h3>
  81.                 <ul>
  82.                 <?php
  83.                 $query = mysqli_query($conn,"select id_berita, judul, tgl, kategori from artikel where kategori LIKE '%sirah%' order by tgl desc limit 5");
  84.                 while($result = mysqli_fetch_array($query)){
  85.                     $judul = strip_tags($result['judul']);
  86.                     $judul2 = substr($judul,0,43);
  87.                     $judul2 = substr($judul,0,strrpos($judul2," "));
  88.                     ?>
  89.                     <li><a href="#" title="<?php echo $result['judul'];?>"><?php echo $judul2." ..";?></a><hr style="margin-top:7px; margin-bottom:7px; border-style:solid;"></li>
  90.                     <?php } ?>
  91.                     <li><a href="#"><b style="color:#286815">Selengkapnya...</b></a></li></ul></div>
  92.                 </div>
  93.             </li><!--end nafsiyah-->
  94.             <li><a href="#">Opini</a>
  95.                 <div class="opini">
  96.                 <div class="nav-opini">
  97.                 <h3>Kajian Internal</h3>
  98.                 <ul>
  99.                 <?php
  100.                 $query = mysqli_query($conn,"select id_berita, judul, tgl, kategori from artikel where kategori LIKE '%kaj_internal%' order by tgl desc limit 5");
  101.                 while($result = mysqli_fetch_array($query)){
  102.                     $judul = strip_tags($result['judul']);
  103.                     $judul2 = substr($judul,0,50);
  104.                     $judul2 = substr($judul,0,strrpos($judul2," "));
  105.                     ?>
  106.                     <li><a href="#" title="<?php echo $result['judul'];?>"><?php echo $judul2." ..";?></a><hr style="margin-top:7px; margin-bottom:7px; border-style:solid;"></li>
  107.                     <?php } ?>
  108.                     <li><a href="#"><b style="color:#286815">Selengkapnya ...</b></a></li></ul></div>
  109.                 <div class="nav-opini">
  110.                 <h3>Analisis</h3>
  111.                 <ul>
  112.                 <?php
  113.                 $query = mysqli_query($conn,"select id_berita, judul, tgl, kategori from artikel where kategori LIKE '%analisis%' order by tgl desc limit 5");
  114.                 while($result = mysqli_fetch_array($query)){
  115.                     $judul = strip_tags($result['judul']);
  116.                     $judul2 = substr($judul,0,50);
  117.                     $judul2 = substr($judul,0,strrpos($judul2," "));
  118.                     ?>
  119.                     <li><a href="#" title="<?php echo $result['judul'];?>"><?php echo $judul2." ..";?></a><hr style="margin-top:7px; margin-bottom:7px; border-style:solid;"></li>
  120.                     <?php } ?>
  121.                     <li><a href="#"><b style="color:#286815">Selengkapnya...</b></a></li></ul></div>
  122.                 <div class="nav-opini">
  123.                 <h3 >Tulisan Mhs/i Fkim</h3>
  124.                 <ul>
  125.                 <?php
  126.                 $query = mysqli_query($conn,"select id_berita, judul, tgl, kategori from artikel where kategori LIKE '%torehan%' order by tgl desc limit 5");
  127.                 while($result = mysqli_fetch_array($query)){
  128.                     $judul = strip_tags($result['judul']);
  129.                     $judul2 = substr($judul,0,50);
  130.                     $judul2 = substr($judul,0,strrpos($judul2," "));
  131.                     ?>
  132.                     <li><a href="#" title="<?php echo $result['judul'];?>"><?php echo $judul2." ..";?></a><hr style="margin-top:7px; margin-bottom:7px; border-style:solid;"></li>
  133.                     <?php } ?>
  134.                     <li><a href="#"><b style="color:#286815">Selengkapnya ...</b></a></li></ul></div>
  135.                
  136.                 </div>
  137.             </li><!--end opini-->
  138.             <li><a href="#">Muslimah</a>
  139.                 <div class="muslimah">
  140.                 <div class="nav-muslimah">
  141.                 <h3>Fiqih Wanita</h3>
  142.                 <ul>
  143.                 <?php
  144.                 $query = mysqli_query($conn,"select id_berita, judul, tgl, kategori from artikel where kategori LIKE '%fiqih_wanita%' order by tgl desc limit 5");
  145.                 while($result = mysqli_fetch_array($query)){
  146.                     $judul = strip_tags($result['judul']);
  147.                     $judul2 = substr($judul,0,50);
  148.                     $judul2 = substr($judul,0,strrpos($judul2," "));
  149.                     ?>
  150.                     <li><a href="#" title="<?php echo $result['judul'];?>"><?php echo $judul2." ..";?></a><hr style="margin-top:7px; margin-bottom:7px; border-style:solid;"></li>
  151.                     <?php } ?>
  152.                     <li><a href="#"><b style="color:#286815">Selengkapnya ...</b></a></li></ul></div>
  153.                 <div class="nav-muslimah">
  154.                 <h3>Mutiara Qolbu</h3>
  155.                 <ul>
  156.                 <?php
  157.                 $query = mysqli_query($conn,"select id_berita, judul, tgl, kategori from artikel where kategori LIKE '%mutiara_qolbu%' order by tgl desc limit 5");
  158.                 while($result = mysqli_fetch_array($query)){
  159.                     $judul = strip_tags($result['judul']);
  160.                     $judul2 = substr($judul,0,50);
  161.                     $judul2 = substr($judul,0,strrpos($judul2," "));
  162.                     ?>
  163.                     <li><a href="#" title="<?php echo $result['judul'];?>"><?php echo $judul2." ..";?></a><hr style="margin-top:7px; margin-bottom:7px; border-style:solid;"></li>
  164.                     <?php } ?>
  165.                     <li><a href="#"><b style="color:#286815">Selengkapnya ...</b></a></li></ul></div>
  166.                 <div class="nav-muslimah">
  167.                 <h3>Sirah Shahabiyah</h3>
  168.                 <ul>
  169.                 <?php
  170.                 $query = mysqli_query($conn,"select id_berita, judul, tgl, kategori from artikel where kategori LIKE '%sirah_shabiyah%' order by tgl desc limit 5");
  171.                 while($result = mysqli_fetch_array($query)){
  172.                     $judul = strip_tags($result['judul']);
  173.                     $judul2 = substr($judul,0,50);
  174.                     $judul2 = substr($judul,0,strrpos($judul2," "));
  175.                     ?>
  176.                     <li><a href="#" title="<?php echo $result['judul'];?>"><?php echo $judul2." ..";?></a><hr style="margin-top:7px; margin-bottom:7px; border-style:solid;"></li>
  177.                     <?php } ?>
  178.                     <li><a href="#"><b style="color:#286815">Selengkapnya ...</b></a></li></ul></div>
  179.                 </div>
  180.             </li><!--end Muslimah-->
  181.             <li><a href="#">Galeri</a></li>
  182.             <li><a href="#">Pendaftaran</a></li>
  183.             <li class="nav-search">
  184.                 <form action="#">
  185.                 <input type="text" placeholder="ketik disini...">
  186.                 <input type="submit" value="">
  187.                 </form></li>
  188.         </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement