在分页页面上通过php显示自定义脚本块

在分页页面上通过php显示自定义脚本块,php,pagination,logic,Php,Pagination,Logic,我必须在分页页面的中心显示一个块 就像这个页面有10个项目的列表一样 我们如何在页面上把它分成两部分,这样在每第五项之后,我就可以显示一个自定义块,该块是启用Javascript的,以便在那里有我们的自定义脚本 寻呼机逻辑 //logic of count $model = &$this->getModel(); $modelCategoryList = &$this->getModel( 'list' ); $newslistTo

我必须在分页页面的中心显示一个块 就像这个页面有10个项目的列表一样

我们如何在页面上把它分成两部分,这样在每第五项之后,我就可以显示一个自定义块,该块是启用Javascript的,以便在那里有我们的自定义脚本

寻呼机逻辑

   //logic of count

$model              = &$this->getModel();
$modelCategoryList  = &$this->getModel( 'list' );
$newslistTotal = $modelCategoryList->get_news_list_total();
$page = (isset($_REQUEST['page'])!="")? $_REQUEST['page'] : 1;
$records_per_page=10;               
$offset = ($page-1) * $records_per_page;

   //display count on the pager page based on logic

      $newslist = $modelCategoryList->get_news_list($offset,$records_per_page);         
    $this->assignRef('newslist'  , $newslist);
查看表单

if(count($this->newslist) >0){

foreach($this->newslist as $newslist)
{
    $list .='<h2><strong>'.$newslist->make.' - '.$newslist->model.'</strong></h2>
    <p>'.$newslist->n_month.' - '.$newslist->year.'</p>
    <p>'.$newslist->list_description.'</p>
    <p></p><hr/>';
        }
 }else{
$list='<div>No Listings.</div>';
  }
   ?>

      <?php echo $list?> 
if(计数($this->newslist)>0){
foreach($this->newslist作为$newslist)
{
$list.=''.$newslist->make'.-'.$newslist->model'.
“.$newslist->n_月。”—“.$newslist->年。”

“.$newslist->list_description”


; } }否则{ $list='No Listings'; } ?>
通过上述逻辑-项目列在页面上,并进一步使用寻呼机逻辑给出页码

如何实现类似的目标 因此,所有包含10个列表的页面 你能像我一样回音吗

      <?php echo $list1?> (of first 5 entries)

    <custom script> ........  </custom script>

      <?php echo $list2?> (of balance 5 entries)
(前5项中)
........  
(余额5分录)

编辑

您可以使用模来编辑

if ($i % 5 === 0) {
   // custom code
}

每次模运算结果为0(每5行)时,它都会显示自定义代码。

你好,埃隆,谢谢,但是我认为我的代码中有一个问题,因为$i integer无法正常工作。我编辑了这个问题。有没有一种方法可以使用$count或通过$newslist执行此操作,这样当计数达到5/15/25/35/45并继续等时,脚本标记可以显示在条目之后和第6/16/26/36/46/56条条目之前like@RuchikaModi不,要做到这一点,您必须像以前一样使用
$i
var,或者将
foreach
更改为
for