Selasa, 23 Juli 2013

PHP Indonesia - Facebook: assalamualaikum...saya mau tanya..saya lagi blajar...

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. NOTE: Rules for Wall posting: https://www.facebook.com/groups/35688476100/doc/10151597056316101/ Daftar Keanggotaan : http://www.facebook.com/groups/35688476100/doc/10150671770741101/ 
assalamualaikum...saya mau tanya..saya lagi blajar...
Jul 24th 2013, 03:38, by Okki Setyawan

Okki Setyawan 3:38am Jul 24
assalamualaikum...saya mau tanya..saya lagi blajar bikin paging pake php...cuma ini selalu muncul.
Undefined index....bla bla bla..
mungkin ada yang tau salah nya dimana...

Okki Setyawan 3:39am Jul 24
ini script nya :
<?php

function buat_paging($curPage,$totalRec,$maxRec){
$totalPage;
$totalPage=ceil($totalRec/$maxRec);
$str="";

/*--------------------------Tombol Prev-----------------------*/

if($curPage>1){
$prevPage = $curPage-1;
$str.=" ".makeLink("prev","?p=".$prevPage)." ";
}

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

for($i=1;$i<=$totalPage;$i++){
if($i==$curPage){
$bold=true;
}else{
$bold=false;
}
$str.=" ".makeLink($i,"?p=".$i,$bold)." ";
}

/*--------------------------Tombol Next-----------------------*/

if($curPage<$totalPage){
$nextPage=$curPage+1;
$str.=" ".makeLink("next","?p=".$nextPage)." ";
}

return $str;

}
function makeLink($str,$url,$bold="false"){
if($bold){
$str="<b>".$str."</b>";
}
return '<a href="'.$url.'">'.$str.'</a>';
}

//connection
$con = mysql_connect("localhost","root","");
mysql_select_db("paging",$con);
$total=mysql_query("select * from berita",$con);
$total=mysql_num_rows($total);
$total=ceil($total/4);
$curPage=abs((int)$_GET['p']);
if ($curPage==null){$curPage=1;}
elseif($curPage>$total){$curPage=$total;}
$maxRec=4;

$startRec = ($curPage-1)*$maxRec;
$sql = "select * from berita limit ".$startRec.",".$maxRec;
$rs=mysql_query($sql,$con);
while ($row = mysql_fetch_array($rs)) {
echo "Ini adalah : ".$row['artikel']."<br />";
}
$total_record=mysql_query("select * from berita",$con);
$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