Tolong pilih kategori sesuai, jenis posting (pertanyaan atau bukan) dan sertakan tag/topik yang sesuai misal komputer, php, mysql, dll.
Promosi atau posting tidak pada tempatnya akan kami hapus.
Klik link berikut untuk informasi cara menyisipkan kode program supaya tampil rapi dan terformat dengan baik di diskusiweb.com: http://www.diskusiweb.com/discussion/50415/cara-menyisipkan-kode-program-di-diskusiweb-com

Baca cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

Help..??Hasil Search dala paging...

contoh proses search

<?php
$keyword = trim($_GET['keyword']);
      $pisah_kata = explode(" ", $keyword);
      $jumlah_kata = (integer)count($pisah_kata);
      $jml_kata = $jumlah_kata - 1;
     
$dataPerPage = 5;
if(isset($_GET['page']))
{ $noPage = $_GET['page'];
} else $noPage = 1;
$offset = ($noPage - 1) * $dataPerPage;
     
      $sql = "SELECT * FROM video JOIN video_cat ON video_cat.cid = video.cid  WHERE  ";
      for ($i=0; $i<=$jml_kata; $i++){
      $sql .= "video.judul LIKE '%$pisah_kata[$i]%'";
      if($i < $jml_kata){
        $sql .= " OR ";
      }}
      $sql .= " ORDER BY video.vid ASC LIMIT $offset, $dataPerPage ";
      $hasil = mysql_query($sql);
      while ($data = mysql_fetch_array($hasil)){
    ?>
            <div class="r">
              <h2><a href="play.php?vid=<?php echo''.$data['vid'].'';?>&cid=<?php echo''.$data['cid'].'';?>&ok=1&<?php echo''.$data['judul'].'';?>"><?php echo''.$data['judul'].'';?></a></h2>
              <p><?php echo''.$data['ket'].'';?></p>
              <p class="details"><a href="http:///">04.23.09</a> |
              <img src="images/aut.png" style="width:13px;height:11px;" /> - <?php echo''.$data['aut'].'';?></p>
              <p class="comments"><a href=""><?php echo''.$data['view'].'';?> views</a></p>
            </div>
<?php } ?>
<p><br><p>
<div class="r" style="margin-top:20px;width:100%;">  

PAGING         
<?php
$res = $_REQUEST['keyword'];
$query   = "SELECT COUNT(*) AS jumData FROM video   ";
$hasil  = mysql_query($query);
$data     = mysql_fetch_array($hasil);
$jumData = $data['jumData'];
$jumPage = ceil($jumData/$dataPerPage);
if ($noPage > 1) echo  "<a href='".$_SERVER['PHP_SELF']."?key=$res&page=".($noPage-1)."' title='mundur'>
<img style='width:20px;height:10px;'src='images/mundur.png' alt=''/>&nbsp;&nbsp;&nbsp;</a>";
for($page = 1; $page <= $jumPage; $page++)
{
         if ((($page >= $noPage - 3) && ($page <= $noPage + 3)) || ($page == 1) || ($page == $jumPage))
         {  
            if (($showPage == 1) && ($page != 2))  echo ". . .";
            if (($showPage != ($jumPage - 1)) && ($page == $jumPage))  echo ". . .";
            if ($page == $noPage) echo " <b>".$page."</b> ";
            else echo " <b><a href='".$_SERVER['PHP_SELF']."?key=$res&page=".$page."' title='halaman-".$page."'>".$page."</a></b> ";
            $showPage = $page;         
         }}
if ($noPage < $jumPage) echo "<a href='".$_SERVER['PHP_SELF']."?key=$res&page=".($noPage+1)."' title='maju'>
&nbsp;&nbsp;&nbsp;<img style='width:20px;height:10px;'src='images/maju.png' alt=''/></a>";
?>

Script proses search udah jalan,,,
pagingnya bila ke page berikut (maju/mundur) bisa hanya sekali klik...
klik selanjutnya halaman jadi tampil semua (tidak berdasar hasil pencarian)...Mohon sarannya Mastah...???

Tagged:

Comments

Sign In or Register to comment.