Jumat, 26 Juli 2013

PHP Indonesia - Facebook: [Ask] kod paging saya sperti ini... yang mau saya ...

PHP Indonesia - Facebook
PHP Indonesia is a community for everyone that loves PHP. Our focus is in the PHP world but our topics encompass the entire LAMP stack. Topics include PHP coding, to memcached handling, db optimizations, server stack, web server tuning, code deploying, hosting options and much much more. Youtube Channel : http://www.youtube.com/user/OurPHPIndonesia NOTE: Rules for Wall posting: https://www.facebook.com/groups/35688476100/doc/10151597056316101/ Daftar Keanggotaan : http://www.facebook.com/groups/35688476100/doc/10150671770741101/ 
[Ask] kod paging saya sperti ini... yang mau saya ...
Jul 27th 2013, 04:17, by Ardian Saputra

Ardian Saputra 4:17am Jul 27
[Ask] kod paging saya sperti ini... yang mau saya tanyakan kenapa waktu di klik next or prev datanya tidak muncul.. mohon pencerahanya!!!!!
<?php
//membuat koneksi ke database
include "./config.php";
function buat_paging($curPage,$totalRec,$maxRec){

$totalPage;

$totalPage=ceil($totalRec/$maxRec);

$str="";

/*————————–Tombol Prev———————–*/

if($curPage>1){

$prevPage = $curPage-1;

$str.="".makeLink('prev','?page='.$prevPage)." ";

}

/*————————-Untuk Page Number—————-*/

for($i=1;$i<=$totalPage;$i++){

if($i==$curPage){

$bold=true;

}else{

$bold=false;

}

$str.="".makeLink($i,'?page='.$i,$bold)."";

}

/*————————–Tombol Next———————–*/

if($curPage<$totalPage){

$nextPage=$curPage+1;

$str.="".makeLink('next','?page='.$nextPage)."";

}

return $str;

}

function makeLink($str,$url,$bold="false"){

if($bold){

$str="<b>".$str."</b>";

} return '<a href="'.$url.'">'.$str.'</a>';

}

//connection
$total=mysql_query("select * from kontak");

$total=mysql_num_rows($total);

$total=ceil($total/4);

$curPage=abs((int)$_GET['page']);

if ($curPage==null){$curPage=1;}

elseif($curPage>$total){$curPage=$total;}

$maxRec=4;

$startRec = ($curPage-1)*$maxRec;

$sql = "select * from kontak order by nama desc limit ".$startRec.",".$maxRec;

$rs=mysql_query($sql);

//menampilkan data
while($rows=mysql_fetch_array($rs)){
//menampilkan field nama
echo "<b>Waktu : </b>".$rows['email'];
echo "<br>";
echo "<b>Nama : </b>".$rows['nama'];

echo "<br><b>Testimoni : </b>".$rows['komentar'];
echo "<br>";
echo "<hr>";
}
$total_record=mysql_query("select * from kontak");

$total_record=mysql_num_rows($total_record);

echo "<br>";

echo buat_paging($curPage,$total_record,$maxRec);
?>

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions

Tidak ada komentar:

Posting Komentar