Zebra_Pagiatio是一个通用的PHP类,用来根据记录数和每页显示数自动生成分页链接。
示例代码:
<?php//let'spagiatedatafromaarray...$coutries=array(//arrayofcoutries);//howmayrecordsshouldbedisplayedoapage?$records_per_page=10;//icludethepagiatioclassrequire'path/to/Zebra_Pagiatio.php';//istatiatethepagiatioobject$pagiatio=ewZebra_Pagiatio();//theumberoftotalrecordsistheumberofrecordsithearray$pagiatio->records(cout($coutries));//recordsperpage$pagiatio->records_per_page($records_per_page);//here'sthemagick:weeedtodisplay*oly*therecordsforthecurretpage$coutries=array_slice($coutries,(($pagiatio->get_page()-1)*$records_per_page),$records_per_page);?><table><tr><th>Coutry</th></tr><?phpforeach($coutriesas$idex=>$coutry):?><tr<?phpecho$idex%2?'class="eve"':'')?>><td><?phpecho$coutry?></td></tr><?phpedforeach?></table><?php//rederthepagiatioliks$pagiatio->reder();?>









评论