rendered paste body<?php
include "frame.php";
include "admin/connect.php";
$page = $_REQUEST["page"];
$err = $_REQUEST["err"];
switch($err){
case '1' : ?> <script language="javascript">alert("Harap Input Kata yang Ingin Dicari"); </script> <?php break;
}
if(!isset($page)){
$page = 0;
}
?>
<div id="wrap">
<div id="main">
<?php
include "b_up.php";
?>
<h1>Hasil Pencarian</h1>
<p>
<?php
$cari = trim($_POST["cari"]);
$temp = explode (" ",$cari);
$j = count ($temp);
if(empty($cari)){
?>
<script language="javascript"> alert("Jangan Maksa Ya ! !"); </script>
</div>
</div>
<?php
include "footer.php";
return;
}
for($i=0;$i<$j;$i++){
$s1 .= "( nama LIKE '%$temp[$i]%')";
$s2 .= "( web LIKE '%$temp[$i]%')";
$s3 .= "( judul LIKE '%$temp[$i]%')";
$s4 .= "( isi LIKE '%$temp[$i]%')";
if ($i != $j-1){
$s1 .= " AND ";
$s2 .= " AND ";
$s3 .= " AND ";
$s4 .= " AND ";
}
}
$offset = $page * 30;
$perintah = "SELECT * FROM baris WHERE ($s1) OR ($s2) OR ($s3) OR ($s4) ORDER BY no DESC";
$hasil = mysql_query($perintah);
$total = mysql_num_rows($hasil);
$sql = "SELECT * FROM baris WHERE ($s1) OR ($s2) OR ($s3) OR ($s4) ORDER BY no DESC LIMIT $offset,30";
$result = mysql_query($sql);
$jmlh = mysql_num_rows($result);
if($jmlh > 0){
echo "<code><b>";
while($baris = mysql_fetch_array($hasil)){
?><a href="ib.php?id=<?php echo $baris['no']; ?>&tit=<?php echo $baris['judul']; ?>"><?php echo $total.". ".$baris['judul']; ?></a><br><br>
<?php
}
echo "</b></code>";
if($total > 0){
echo "<h1>Sebanyak $total Artikel Ditemukan</h1>";
}
else if($total == 0){
?>
<script language="javascript">alert("Tidak Ditemukan Iklan Tersebut");</script>
<?php
}
}
?>
<?php
$hal = ceil($total / 30);
if($page > -1){
?>
<p align="center">
<br />
<?php
if($page >0 AND $cari !=""){
?>
<p align="center"><a href="search.php?page=<?= $hal-1; ?>"> << Previous </a>
<?php
}
?>
Page <?php $paging = $page +1; echo ($page+1) ?> of <?php echo $hal; ?>
<?php
if($page < ($hal-1) ){
?>
<a href="search.php?page=<?= $hal+1; ?>"> >> Next </a>
<?php
}
}
else{
header("location:search.php?page=0&err=1");
}
mysql_close($con);
?>
</p>
</div>
</div>
</p>
<?php
include "footer.php";
?>
</html>