Codeigniter pagination showing duplicate records with page query string - php

i have created pagination with codeigniter 3.
On every page i am getting same results:
my final url seems like: http://localhost/shoping/products/mobile-phones?cid=3&page=2
Controller file:
public function category(){
$category_id = $this->input->get('cid', TRUE);
$slug = $this->uri->segment(2);
$sortby = $this->input->get('sort', TRUE);
$sorttype= 'ASC';
$limit = 10;
$config = array();
$config['base_url'] = base_url() . 'products/'.$slug.'?cid='.$category_id;
$config['total_rows'] = $this->Product_model->category_product_count($category_id);
$config['per_page'] = $limit;
$config['use_page_numbers'] = TRUE;
$config['page_query_string'] = TRUE;
$config['query_string_segment'] = 'page';
// $config["uri_segment"] = 3;
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '</li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['prev_link'] = '«';
$config['next_link'] = '»';
$config['cur_tag_open'] = '<li><a class="current">';
$config['cur_tag_close'] = '</a></li>';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$choice = $config["total_rows"] / $config["per_page"];
$config["num_links"] = round($choice);
$this->pagination->initialize($config);
if($this->uri->segment(2) > 0){
$page = ($this->uri->segment(2) + 0)*$config['per_page'] - $config['per_page'];
}
else{
$page = $this->uri->segment(2);
}
$data["links"] = $this->pagination->create_links();
if($data["links"]!= '') {
$data['pagermessage'] = 'Showing '.((($this->pagination->cur_page-1)*$this->pagination->per_page)+1).' to '.($this->pagination->cur_page*$this->pagination->per_page).' of '.$config['total_rows'];
}
if($this->input->get('sort')=='pricelow'){
$sortby = 'price';
$sorttype= 'ASC';
}
elseif($this->input->get('sort')=='pricehigh'){
$sortby = 'price';
$sorttype= 'DESC';
}
elseif($this->input->get('sort')=='new'){
$sortby = 'updated_on';
$sorttype= 'DESC';
}
elseif($this->input->get('sort')=='popularity'){
$sortby = 'price';
$sorttype= 'DESC';
}
else{
$sortby = 'title';
$sorttype= 'ASC';
}
//Get all products
$data['products_by_category'] = $this->Product_model->get_products_by_category($category_id, $config["per_page"], $page, $sortby, $sorttype);
// echo $config['total_rows'];
// Load View
$data['main_content'] = 'public/products_category';
$this->load->view('public/layouts/home_main', $data);
}
Model File:
public function get_products_by_category($category_id, $limit, $start='', $shortby='', $shorttype=''){
$this->db->select('*');
$this->db->where('category_id', $category_id);
$this->db->limit($limit, $start);
$this->db->order_by($shortby, $shorttype);
$query = $this->db->get('products');
if($query->num_rows() > 0){
return $query->result();
}else{
return false;
}
}
and view file:
<?php foreach($products_by_category as $product): ?>
<div class="col-sm-4 col-md-4 col-lg-3">
<div class="single-product" style="height:300px;margin-bottom:10px">
<span class="sale-on">sale</span>
<div class="product-image">
<div class="show-img">
<a href="<?php echo base_url();?><?php echo $product->slug.'?sid='.$product->id;?>">
<img src="<?php echo base_url(); ?>assets/images/products/<?php echo $product->image;?>" alt="<?php echo $product->title;?>" height="150" width="150">
</a>
</div>
</div>
<div class="prod-info">
<h2 class="pro-name">
<?php echo $product->title.$product->id;?>
</h2><br>
<div class="price-box">
<div class="price">
<span><i class="fa fa-inr"></i><?php echo $product->price;?></span>
</div>
<div class="old-price">
<span><i class="fa fa-inr"></i><?php echo $product->mrp_price;?></span>
</div>
</div>
<div class="actions">
<span class="new-pro-wish">
<i class="fa fa-heart-o"></i>
</span>
<span class="new-pro-compaire">
<i class="fa fa-bar-chart"></i>
</span>
</div>
</div>
</div>
</div>
<?php endforeach; ?>

Instead of $this->uri->segment(2), use $this->input->get('page', TRUE).
See CI_Input::get for more information on how you can get query string variables.

Related

Codeigniter - Pagination not working

I'm having some problems with Codeigniter and the pagination. The problem is that I get all the results/posts on all pages.
I'm having some problems with Codeigniter and the pagination. The problem is that I get all the results/posts on all pages.
Here is my Controller Code:
public function __construct()
{
parent::__construct();
$this->load->model('SS_shilpi_model');
$this->load->library('form_validation');
$this->load->library('pagination');
}
public function category(){
$cid = $this->input->post('cid');
if(isset($_GET['cid']))
{
$cid = $_GET['cid'];
$this->SS_shilpi_model->catr3($cid);
$this->SS_shilpi_model->catr3_nr($cid);
}
$config = [
'base_url' => base_url('category/?cid='. $cid .' '),
'per_page' => 12,
'total_rows' => $this->SS_shilpi_model->catr3_nr($cid),
];
$config['full_tag_open'] = '<ul style="overflow: hidden;" class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['num_tag_open'] = '<li class="page-item">';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="page-item active"><a class="page-link" href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['next_tag_open'] = '<li class="page-item">';
$config['next_tagl_close'] = '</a></li>';
$config['prev_tag_open'] = '<li class="page-item">';
$config['prev_tagl_close'] = '</li>';
$config['first_link'] = 'First <i class="fa fa-caret-left fa-2x push-left-5 pull-right green-text"></i>';
$config['first_tag_open'] = '<li class="page-item disabled">';
$config['first_tagl_close'] = '</li>';
$config['last_link'] = '<i class="fa fa-caret-right fa-2x push-left-5 pull-right green-text"></i> Last';
$config['last_tag_open'] = '<li class="page-item">';
$config['last_tagl_close'] = '</a></li>';
$config['attributes'] = array('class' => 'page-link');
$this->pagination->initialize($config); // model function
$data['catr3d'] = $this->SS_shilpi_model->catr3($cid, $config['per_page'], $this->uri->segment(3)); // list of Category Details
// end pagination
$this->load->view('shilpi/category',$data);
}
My Model Code :
public function catr3($cid){
$this->db->select('');
$this->db->order_by('id', 'DESC');
$this->db->where('category_id',$cid);
$query = $this->db->get('all_posts');
return $query->result();
}
public function catr3_nr($cid){
$this->db->select('');
$this->db->order_by('id', 'DESC');
$this->db->where('category_id',$cid);
$query = $this->db->get('all_posts');
return $query->num_rows();
}
My view code :
<div id="catdata" class="col-xs-12 no-pull push-up-5 push-down-5 briefs">
<?php
$count =1;
foreach($catr3d as $r)
{
if($count%4 == 1)
{
echo '<div class="col-xs-12 no-pull push-down-5">';
}
?>
<div class="col-sm-3 col-xs-12 no-pull-left pull-right-5">
<div class="brief whitish-bg pull-5">
<p class="red-text no-push">
<?php echo $r->short_title; ?>
</p>
<a href="<?php echo base_url(); ?>details/?pid=<?php echo $r->id; ?>">
<h5 class="blue-text font17 push-up-5">
<?php echo $r->title; ?>
</h5>
</a>
<p>
<a href="<?php echo base_url(); ?>details/?pid=<?php echo $r->id; ?>">
<img src="<?php echo base_url(); ?>upload/images/<?php echo $r->photo;?>" height="75" width="100" class="pull-left push-right-5 push-up-5"></img>
</a>
<?php
$string = $r->news;
$string = strip_tags($string);
if (strlen($string) > 500) {
$pos=strpos($string, ' ', 900);
$stringCut=substr($string,0,$pos );
echo $stringCut;
}
else {
echo $string;
}
?>
<i class="fa fa-caret-right fa-2x push-left-5 pull-right green-text"></i>
</p>
</div>
</div>
<?php
if ($count%4 == 0)
{
echo "</div>";
}
$count++;
?>
<div class="clear: both"></div>
<?php
}
if ($count%4 != 1) echo "</div>";
?>
<?= $this->pagination->create_links() ?>
</div>
Add This to Controller start and limit to your model function argument
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['posts'] = $this->post->get_posts($config["per_page"], $page);
And following to model function get_posts
$this->db->limit($limit, $start);

codeigniter pagination in multiple table joins displying error Invalid argument supplied for foreach()

I have a problem with pagination.when I click on the next but it brings the above error, but when I click on the previous link it works normally. here is my code for the controller:
public function categoryfour()
{
$config = array();
$config["base_url"] = base_url() . "bulletins/categoryfour";
$total_row = $this->news_model->record_count_category_four();
$config["total_rows"] = $total_row;
$config["per_page"] = 2;
$config["uri_segment"] = 3;
$config['use_page_numbers'] = TRUE;
$config['num_links'] = $total_row;
$config['cur_tag_open'] = ' <a class="current">';
$config['cur_tag_close'] = '</a>';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["posts"] =$this->news_model->get_news_cat_four($config["per_page"], $page);
$str_links = $this->pagination->create_links();
$data["pages"] = explode(' ',$str_links );
$this->load->view('category_one',$data);
}
here is the code for the model:
function get_news_cat_four($limit, $start)
{
$this->db->select('news.id as newsId,news_category.id as catId,users.id as userId,news.*,news_category.*,users.*,comments.*, COUNT(comments.post_id) as num_comments');
$this->db->join('users' , 'users.id = news.user_id');
$this->db->join('news_category' , 'news_category.cat_id = news.news_id');
$this->db->join('comments' , 'comments.post_id = news.id');
$this->db->group_by('comments.post_id');
$this->db->order_by('news.date_added','desc');
$this->db->where('news.news_id',4);
$this->db->limit($limit, $start);
$query = $this->db->get("news");
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;}
and finally the view:
<div id="page-content" class="single-page container">
<div class="gutter-7px">
<div id="main-content" class="col-md-8 fix-right">
<article class="single-post">
<?php if(count($posts)) {
foreach($posts as $n){ ?>
<div class="entry-header">
<h1 class="entry-title"><?php echo $n->title;?></h1>
<span> <i class="fa fa-calendar"></i> <?php echo date( 'F jS, Y g:i a' , strtotime($n->date_added))?>/
<i class="fa fa-comment-o"></i>
<?php echo $n->num_comments;?>/<i class="fa fa-user"></i>
<?php echo $n->username?></span>
</div>
<div class="post-thumbnail-wrap"><a href="<?php echo base_url();?>bulletins/view/<?php echo $n->newsId?>"><img src="<?php echo base_url('assets/images/'.$n->image)?>"
style="width:800px;height:500px" /></a></div>
<div class="entry-content">
<p><?php echo substr(strip_tags($n->content), 0, 200).'...';?></p>
Read More...
<?php }}?>
</div>
</article>
<div id="pagination">
<ul class="pagination">
<!-- Show pagination links -->
<?php foreach ($pages as $link) {
echo "<li>". $link."</li>";
}
?>
</div>
</div>
</div>

how to solve pagination second page link for displaying details?

I am doing pagination in CodeIgniter.
Data is loading correctly but when I click on next, it will display a blank page.
Everything is configured properly.
Loaded pagination library also.
But that link is not working.
My model is:
public function record_count_apartment() {
return $this->db->count_all("apartments");
}
function get_apartment_details($limit, $start)
{ $this->db->limit($limit, $start);
$this->db->select('*');
$this->db->from('apartments');
$query = $this->db->get();
return $query->result();
}
My controller is:
$config = array();
$config["base_url"] = base_url() . "search";
$config["per_page"] = 1;
$config["uri_segment"] = 2;
$config['cur_tag_open'] = ' <a class="current">';
$config['cur_tag_close'] = '</a>';
$config['num_links'] = 2;
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$config['use_page_numbers'] = TRUE;
$config["total_rows"] = $this->get_search_details_model->record_count_apartment();
$this->pagination->initialize($config);
$page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
$data['apartments'] = $this->get_search_details_model->get_apartment_details($config["per_page"], $page );
$data["links"] = $this->pagination->create_links();
//print_r($data);
$this->layouts->view('user/user_apartments_view', array('left_sidebar' => 'sidebar/left_sidebar','right_sidebar' => 'sidebar/right_sidebar'),$data,TRUE);
My view is:
<div class="container">
<div class="container col-lg-12 " style="background-color:#49BF4C; margin-top:0.5em;">
<div class="col-lg-12">
<strong> <h3 style="color:white; font-weight:900; font-size:1.5em; text-align:center; ">Apartments</h3> </strong>
</div>
</div>
<?php
foreach( $apartments as $apartment) { ?>
<div class="col-lg-3">
<?php echo $apartment->a_name;?> <br>
<?php echo $apartment->a_cityname;?> <br>
<?php echo $apartment->a_desc;?> <br>
</div>
<?php } ?>
<div class="col-lg-12">
<?php echo $links; ?>
</div>
</div>
if you are using the bootstrap framework, use below pagination code customized for bootstrap:-
$config["base_url"] = base_url() . "search";
$config['total_rows'] = $this->get_search_details_model->record_count_apartment();
$config['per_page'] = 10;
$config['num_links'] = 2;
$config['uri_segment'] = 3;
$config['full_tag_open'] = '<ul class="pagination pagination-sm no-margin pull-right">';
$config['full_tag_close'] = '</ul>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#"><b>';
$config['cur_tag_close'] = '</b></a></li>';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '</li>';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['page_query_string'] = TRUE;
$config['query_string_segment'] = 'page';
$this->pagination->initialize($config);
$data['links'] = $this->pagination->create_links();
$data['apartments'] = $this->get_search_details_model->get_apartment_details($config["per_page"], $page );
$this->layouts->view('user/user_apartments_view', array('left_sidebar' => 'sidebar/left_sidebar','right_sidebar' => 'sidebar/right_sidebar'),$data,TRUE);
I think problem is in your configuration of pagination library
$config["base_url"] = base_url() . "search";
$config["per_page"] = 1;
$config["uri_segment"] = 2;
Instead of above code you should write
$config["base_url"] = base_url() . "search/index";
$config["per_page"] = 1;
$config["uri_segment"] = 3;

Simple Pagination to blog written in codeigniter

I am trying to create a simple pagination in my CodeIgniter blog, here is my code, I am using auto loader for these
$autoload['libraries'] = array('database','session','pagination');
$autoload['helper'] = array('form','url');
My Controller;
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Blog extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('BlogModel');
}
public function index($offset=0)
{
$this->load->library('table');
$config["base_url"] = base_url('blog');
//$config["total_rows"] = $this->BlogModel->get_Count(); // There are currently 36 Posts
$config["total_rows"] = 36; // There are currently 36 Posts
$config["per_page"] = 5; // Change limit to suit what you would like
$config['use_page_numbers'] = TRUE;
$limit = $config['per_page'];
$this->pagination->initialize($config);
$blog_pagination = $this->pagination->create_links();
$Posts = $this->BlogModel->get_Posts($limit, $offset);
$assignData=array('data'=>$Posts,'blog_pagination'=>$blog_pagination);
$this->load->view('header');
$this->load->view('blog', $assignData);
$this->load->view('footer');
}
}
I Have this in my Model;
<?php
class BlogModel extends CI_Model {
public function __construct(){
// Call the Model constructor
parent::__construct();
$this->load->library('memcached_library');
}
public function get_Posts($limit, $offset){
$this->db->select('*');
$this->db->where('post_status','published');
$query= $this->db->get('cms_posts',$limit, $offset);
$data=$query->result_array();
return $data;
}
public function get_Count() {
//$query = $this->db->get($this->db->dbprefix . 'blog');
$this->db->select('*')->from('cms_posts');
$this->db->where('post_status','published');
$query= $this->db->get();
//$data=$query->result_array();
return $query->num_rows();
}
}
?>
I am using this in my View;
<div id="primary" class="left-column">
<?php
if(!empty($data)){
foreach($data as $row){
?>
<main id="main" role="main">
<article id="<?php echo $row['post_id']; ?>" class="post-item">
<div class="right">
<div class="post-thumbnail">
<img src="<?php echo base_url()."assets/images/uploads/test_n-150x150.jpg";?>" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" sizes="(max-width: 320px) 100vw, 320px" width="320" height="143">
</div>
<!-- END .post-thumbnail -->
</div>
<div class="left">
<h2 class="post-title">
<?php echo $row['post_title']; ?>
</h2>
<div class="post-meta">
<span class="vcard author">
<?php echo ucwords($row['post_author']); ?>
</span>
<time class="entry-date published" datetime="<?php echo $row['post_date']; ?>"><?php echo date("d M Y", strtotime($row['post_date'])); ?></time>
</div>
<div class="post-excerpt">
<p>
<?php
echo(substr($row['post_content'], 0, 250));
<a class="read-more" href="<?php echo base_url()."blog/".$row['post_url']; ?>">Read More »</a>
</p>
</div>
<!-- END .post-excerpt -->
</div>
<!-- END .left -->
</article>
<!-- END .post-item -->
</main>
<?php
}
}
?>
<!-- END .site-main -->
<div class="pagination-wrap">
<?php echo $blog_pagination; ?>
</div>
</div>
EDIT:
My Route is as under:
$route['default_controller'] = 'index';
$route['blog/:any'] = 'blog/post/$1';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
I don't know that what and where are I am missing something, please lead me or correct me in this code. thnk you
Update
My Blog show now 5 Post on First Page and create Pagination but on only 123>Last› pagination is created and there is page blank on offset 2 (/blog/2).
maybee you can use my methode use uri segment to $offset, like this
public function house()
{
$config['base_url'] = site_url().'/user/house/';
$config['total_rows'] = $this->houses->select_row_house_design();
$config['per_page'] = 12;
$config['cur_tag_open'] = '<li><a><b>';
$config['cur_tag_close'] = '</li></a></b>';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '</li>';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$this->pagination->initialize($config);
$from = $this->uri->segment('3');
$data['design'] = $this->houses->select_all_house_design($config['per_page'],$from);
$title['menu'] = 'house design';
$this->template('user/house',$data,$title);
}
set controller like this,
this is also simple
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Blog extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('BlogModel');
$this->load->library('table');
}
public function index($offset=0)
{
$config['base_url'] = site_url('blog/index');
$config["total_rows"] = $this->BlogModel->get_Count(); // There are currently 36 Posts
$config["per_page"] = 5; // Change limit to suit what you would like
$config['num_links'] = 10;
/*use this code for bootstrap
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a class="">';
$config['cur_tag_close'] = '</a></li>';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '<li>';
$config['next_tag_open'] = '<li class="next">';
$config['next_tag_close'] = '</li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['first_link'] = '<<';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['last_link'] = '>>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
*/
$this->pagination->initialize($config);
$data['blog_pagination'] = $this->pagination->create_links();
$data['posts'] = $this->BlogModel->get_Posts($config['per_page'],$this->uri->segment(3));
$this->load->view('header');
$this->load->view('blog', $data);
$this->load->view('footer');
}
}

Codeigniter PHP Foreach duplicate post

img
Every time I add a second comment, my post is duplicated. This appeared when I included comments in the system.
My code is below. Posts are duplicated every time I add a new comment.
1 comment = 1 post; 2 comments = 2 post; 3 comments = 3 post[...]
My Controller:
public function index()
{
if($this->session->userdata('u_logged') == TRUE)
{
$config = array();
$config['base_url'] = base_url().'core/index';
$config['total_rows'] = $this->core_model->types_count();
$config['per_page'] = 4;
$config['uri_segment'] = 3;
$config['use_page_numbers'] = TRUE;
$config['full_tag_open'] = "<ul class='pagination noborder'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled noborder'><li class='active noborder'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['results'] = $this->core_model->fetchTypes($config['per_page'], $page);
$data['links'] = $this->pagination->create_links();
$data['notifications'] = $this->core_model->getLastNotifications();
$this->loadTemplate('pages', 'index_view', $data);
if(!empty($this->input->post('comm')))
{
$this->core_model->addComment();
}
}
else if($this->session->userdata('u_logged') == FALSE)
{
$this->loadTemplate('pages', 'index_view', '0');
}
}
My Model
public function types_count()
{
return $this->db->count_all('types');
}
public function fetchTypes($limit, $start)
{
$this->db->limit($limit, $start);
$this->db->order_by('t_id', 'DESC');
$this->db->from('types');
$this->db->join('comments', 'comments.c_type_id = types.t_id');
$query = $this->db->get();
if($query->num_rows() > 0)
{
foreach($query->result() as $row)
{
$data[] = $row;
}
return $data;
}
return false;
}
public function addComment()
{
$text = $this->input->post('inputComment');
$authorid = $this->session->userdata('u_id');
$typeid = $this->input->post('t_id');
$this->db->select('c_date');
$this->db->where('c_author', $authorid);
$query = $this->db->get('comments');
$data = $query->result();
if($query->num_rows() > 0)
{
if($data[0]->c_date - time() < -120)
{
$data = array(
'c_author' => $authorid,
'c_date' => time(),
'c_show' => '1',
'c_text' => $text,
'c_type_id' => $typeid
);
$this->db->insert('comments', $data);
}
else
{
echo 'poczekaj';
}
}
else
{
$data = array(
'c_author' => $authorid,
'c_date' => time(),
'c_show' => '1',
'c_text' => $text,
'c_type_id' => $typeid
);
$this->db->insert('comments', $data);
}
}
**And the view**
<?php foreach($results as $type) { ?>
<div class="panel panel-default noborder">
<div class="panel-body">
<div class="media noboder">
<div class="media-left">
<img class="media-object" style="width: 48px;" src="https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/13413743_1729080443973113_1289643015497858641_n.jpg?oh=98e497c14d65c2102bd9a41777447937&oe=582E9E1E">
</div>
<div class="media-body">
<h4 class="media-heading"><strong>Rafał Chojnowski</strong><small class="pull-right"><?php if($type->t_type_for == '0') { echo 'TYP DARMOWY'; } else { echo 'TYP PREMIUM'; } ?></small></h4>
<small><?php echo mdate($dateString, $type->t_date); ?></small><br />
<p>
<?php echo $type->t_match.', liga '.$type->t_league.', typ '.$type->t_type.', rozpocznie się '.$type->t_start_date.'. Kurs: '.$type->t_course.' '.$type->t_comment; ?>
</p>
</div>
<hr>
<?php foreach($results as $comment) { ?>
<div class="media-left">
<img class="media-object" style="width: 32px;" src="https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/13001028_1523205167987703_4311803603524761516_n.jpg?oh=fb2068c87060975ab7187cde7f1a161f&oe=57EA8DA5">
</div>
<div class="media-body">
<h6 class="media-heading"><strong>Tomasz Chwicewski</strong> <small><?php echo mdate($dateString, $comment->c_date); ?></small></h6>
<?php echo $comment->c_text; ?>
</div>
<br />
<?php } ?>
<?php $hidden = array('t_id' => $type->t_id, 'c_author' => $this->session->userdata('u_id'), 'comm' => '1'); ?>
<?php echo form_open('core/index', '', $hidden); ?>
<div class="input-group">
<input type="text" class="form-control input-sm noborder" name="inputComment" placeholder="Dodaj komentarz">
<span class="input-group-btn">
<button class="btn btn-primary btn-sm noborder" type="submit">Dodaj</button>
</span>
</div>
<?php echo form_close(); ?>
</div>
</div>
</div>
<?php } ?>

Categories