分页codeigniter3与bootstrap 3

时间:2018-05-20 13:20:00

标签: php twitter-bootstrap-3 codeigniter-3

我会在我的网站上加分,但我有问题。 这是我的控制器

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Beritasekolah extends CI_Controller {

function __construct(){
    parent:: __construct();
$this-> load->model('m_beritasekolah');
}
public function index()
{ 

    $data['beritasekolah'] = $this-> m_beritasekolah-> list_beritasekolah();
    $this-> template-> load('static','beritasekolah',$data);

}
public function readmore()
{
    $id = $this-> uri-> segment(3);
    $data['beritasekolah'] = $this-> m_beritasekolah-> list_beritasekolah_single($id);
    $this-> template-> load('static','readmore1',$data);
}
}`

这是我的模特

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class M_beritasekolah extends CI_Model {

public function list_beritasekolah()
{
    $beritasekolah = $this-> db-> query('SELECT * FROM beritasekolah;');
    return $beritasekolah;
}
public function list_beritasekolah_single($id){
    $single = $this-> db-> select('*')
                        -> from('beritasekolah')
                        -> where('id_beritasekolah',$id)
                        -> get();
    return $single;
}
}

和我的观点

    <div class="section">
        <!-- CONTAINER -->
        <div class="container">
            <!-- ROW -->
            <div class="row">
                <!-- Main Column -->
                <div class="col-md-12">
                    <!-- section title -->
                    <div class="section-title">
                        <h2 class="title">Berita Sekolah</h2>
                    </div>
                    <!-- /section title -->
                    <?php foreach ($beritasekolah-> result() as $key) { ?>
                    <!-- ARTICLE -->
                    <article class="article row-article">
                        <div class="article-img">
                                <img src="data:image/jpeg;base64,<?php echo base64_encode($key-> gambar); ?>" />
                        </div>
                        <div class="article-body">
                            <h3 class="article-title"><a href="post.html"><?php echo $key-> judul_berita;?></a></h3>
                            <?php echo $key-> isi_berita;?>
                        </div>
                    </article>
                    <!-- /ARTICLE -->

                    <?php }?>
               <?php echo $this->pagination->create_links(); ?>

                </div>`
            </div>
        </div>
    </div>

谢谢你:)

0 个答案:

没有答案