2014-04-08 80 views
-1

我在警予framework.I是新在做一個選擇數據形式的數據庫,並列出其與pagination.my控制器Sitecontroller.php,查看文件是search_result.php不工作分頁使用Yii框架

控制器 - Sitecontroller .PHP

<?php 
class SiteController extends Controller 
{ 
public function actionsearch_result() 
    { 
    $title=$_GET['title']; 
    $experience=$_GET['experience']; 
    $criteria=new CDbCriteria(); 
    $count=Job::model()->count($criteria); 
    $pages=new CPagination($count); 
    $pages->pageSize=2; 
    $pages->applyLimit($criteria); 
    $model=Job::model()->findAll(array('select'=>'*', 
"condition"=>"(title like  '%$title%') 
or (key_skills like '%$title%')",)); 
    $this->render('search_result',array('model' =>$model,'title' =>$title, 
    'experience' =>$experience,'pages' => $pages)); 

    } 

} ?>

查看-search_result.php

<div style="float:right;margin-right:285px;"> 
    <h1>Search Results</h1> 
    <ul style="list-style:none; "> 
    <?php 

foreach($model as $models) 
    { 
$job_id=$models->id; 
?> 
    <li><p><?php echo $models->title; ?></p> 

    <p><?php echo $models->company_name; ?></p> 
    <p><?php echo $models->description; ?></p> 
    <p>Keyskill:<?php echo $models->key_skills; ?><p> 

    </li> 
    <?php 
    } 
    ?> 
</ul>  
    <p><?php $this->widget('CLinkPager', array(
    'pages' => $pages, 
    )) ?></p> 

有人幫幫我嗎?

回答