qeephp コンテンツ ページング_PHP チュートリアル

WBOY
リリース: 2016-07-13 17:52:21
オリジナル
1210 人が閲覧しました

検索項目が多い場合は、ページ単位でデータを表示することができます。

ユーザーテーブルの構造は図に示すとおりです:

qeephp コンテンツ ページング_PHP チュートリアル

ここで、ユーザーをリストの形式で表示したいとします。明らかに、クエリ結果を 1 ページに表示するには、まずページング コントロールの page.php をプロジェクトの制御ファイルにコピーします。次に、コントローラーに次のコードを入力します:

01
関数actionCusList()
02
{
03
$cus_info = ユーザー::find();
04
// 現在のページを取得します
05
$page = intval( $this->_context->page );
06
$page 07
//各ページに表示される番号を設定します
08
$page_size = 10;
09
                                                      10
//条件でユーザーを検索
11
If($id = $this->_context->get('cus_id'))
12
$cus_info->where('id = ?', $id);
13
それ以外
14
{
15
If($first_name = $this->_context->get('first_name'))
16
$cus_info->where('first_name = ?', $first_name);
17
                                                      18
If($last_name = $this->_context->get('last_name'))
19
$cus_info->where('last_name = ?', $last_name);
20
                                                      21
If($email = $this->_context->get('email'))
22
$cus_info->where('email = ?', $email);
23
                                                  24
If($code = $this->_context->get('code'))
25
$cus_info->where('pro_id = ?', Program::find('code = ?', $code)->getOne()->id);
26
}
27
                                                       28
$cus_info->limitPage($page, $page_size);
29
$cus = $cus_info->getAll();
30
                                                                                        31
// レンダービュー
32
$this->_view['url_args'] = $this->_context->get();
33
$this->_view['ページネーション'] = $cus_info->getPagination();
34
$this->_view['cus'] = $cus;
35
}
このコードの 1 つは、条件に基づいてユーザーを検索することです。ユーザーが特定の条件を入力してユーザーを検索できるように、フロントエンドでフォームを設計できます。コードは次のとおりです。

01


02
        Search >
03
       

04
   

05
   
06
   
35
                
36
   

37
      _control('page', 'p', array('pagination' => $pagination, 'url_args' => $url_args));?>
38
   

39
   
40
     
41
       
42
           
43
           
44
           
45
           
46
           
47
           
48
           
49
       
50
      頭>
51
     
52
     
53
       
54
         
55
         
56
         
57
         
58
         
59
         
60
         
63
       
64
    
65
    
66
    表>
67
   

68
      _control('page', 'p', array('pagination' => $pagination, 'url_args' => $url_args));?>
69
   

分页关键代次:

1
_control('page', 'p', array('pagination' => $pagination, 'url_args' => $url_args));?>
显示結果如图:

qeephp コンテンツ ページング_PHP チュートリアル


作者:フライラン

www.bkjia.comtru​​ehttp://www.bkjia.com/PHPjc/478118.html技術記事ユーザー テーブルの構造は、図のようなものです。 リスト形式でユーザーに表示することはできますが、...
カスタム。 ID メールアドレス プログラム 最終ログイン アクション

61
            表示
62
         
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!