below is my Controller :
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Site extends CI_Controller {
public function __construct() {
parent::__construct();
$this->err_msg_model = $this->config->item('err_msg_model');
$this->err_code = $this->config->item('err_code_model');
$this->err_code_success = $this->config->item('err_code_success');
$this->default_reset_pass = $this->config->item('password_default_reset');
$this->load->helper('form');
}
public function index() {
$this->load->model('site_model', '', TRUE);
$this->load->library('pagination');
$this->load->library('table');
$limit = 10;
if ($this->uri->segment(3) === null) {
$offset = 0;
} else {
$offset = $this->uri->segment(3);
}
$config['base_url'] = 'http://localhost/gundaling/site/index/';
$config['total_rows'] = $this->db->get('data')->num_rows();
$config['per_page'] = $limit;
$config['num_links'] = 20;
$queryz = $this->site_model->reportpage2($offset, $limit);
$result = @json_decode($queryz);
$code7 = "";
if ($result != "") {
$code7 = $result->code;
$message = $result->message;
$data['result_select_survey'] = "-";
} else {
$data['result_select_survey'] = "";
}
if ($queryz->num_rows() > 0) {
$cupu = $queryz->row();
$test = $cupu->id;
echo $test;
echo "good :)";
} else {
echo "bad :(";
}
$this->pagination->initialize($config);
$data['records2'] = $queryz;
$this->load->view('template-web/vhead');
$this->load->view('template-web/vheader');
$this->load->view('template-web/site_view', $data);
$this->load->view('template-web/vfooter');
}
}
And Below is my Model :
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Site_model extends CI_Model {
function __construct() {
parent::__construct();
}
// Count all record of table "contact_info" in database.
public function reportpage($offset, $limit) {
$query = "SELECT * FROM data "
. "LIMIT $offset,$limit";
log_message('DEBUG', $query);
if ($this->db->simple_query($query)) {
$result = $this->db->query($query);
} else {
$err_log = $this->db->error();
$err_log = json_encode($err_log);
log_message('ERROR', $err_log);
$result = $err_log;
}
return $result;
}
public function reportpage2($offset, $limit) {
$query = "SELECT * FROM data LIMIT $offset,$limit";
log_message('DEBUG', $query);
if ($this->db->simple_query($query)) {
$result = $this->db->query($query);
} else {
$err_log = $this->db->error();
$err_log = json_encode($err_log);
log_message('ERROR', $err_log);
$result = $err_log;
}
return $result;
}
}
?>
And Below is my View :
<div class="c-layout-page">
<!-- BEGIN: PAGE CONTENT -->
<div id="container">
<h1>Super Pagination with Code Igniter</h1>
<?php foreach($records2->result() as $row){
echo "<p>".$row->id . " : ".
$row-> title . " - ". $row->content."</p>";
}
?>
<?php echo $this->pagination->create_links(); ?>
</div>
</div>
Everything works fine actually, until I load title and content from database:$row-> title . " - ". $row->content."</p>";
I realized that new line in database will not going to convert as <br/>
when it get loaded. I mean, let's see this below Data from my SQL :
|id | title | content
|1 | Hadirilah | Bismillahirrohmanirrohim
| | Kajian Wedding Series #6 | Assalamu`allaikum
| | "Karamnya Sebuah Kapal" | warohmatullahi wabarokatuh
The title and Content are using newline !
Even, when I inspect the element from phpmyadmin, it gave me :<span>Hadirilah Kajian Wedding Series #6 <br>
"Karamnya Sebuah Kapal"</span>
So whats wrong with my script ? Please kindly help. :(