Welcome Guest, Not a member yet? Register   Sign In
I can't make a news system
#3

Hello, look my code

News_model:
PHP Code:
<?php
class News_model extends CI_Model {

 
       public function __construct()
 
       {
 
               $this->load->database();
 
       }
}
CREATE TABLE news (
 
       id int(11NOT NULL AUTO_INCREMENT,
 
       title varchar(128NOT NULL,
 
       slug varchar(128NOT NULL,
 
       text text NOT NULL,
 
       PRIMARY KEY (id),
 
       KEY slug (slug)
);
public function 
get_news($slug FALSE)
{
 
       if ($slug === FALSE)
 
       {
 
               $query $this->db->get('news');
 
               return $query->result_array();
 
       }

 
       $query $this->db->get_where('news', array('slug' => $slug));
 
       return $query->row_array();


News Controller:
PHP Code:
<?php
class News extends CI_Controller {

 
       public function __construct()
 
       {
 
               parent::__construct();
 
               $this->load->model('news_model');
 
               $this->load->helper('url_helper');
 
       }

 
       public function index()
{
 
       $data['news'] = $this->news_model->get_news();
 
       $data['title'] = 'News archive';

 
       $this->load->view('templates/header'$data);
 
       $this->load->view('news/index'$data);
 
       $this->load->view('templates/footer');
}

public function 
view($slug NULL)
{
 
       $data['news_item'] = $this->news_model->get_news($slug);

 
       if (empty($data['news_item']))
 
       {
 
               show_404();
 
       }

 
       $data['title'] = $data['news_item']['title'];

 
       $this->load->view('templates/header'$data);
 
       $this->load->view('news/view'$data);
 
       $this->load->view('templates/footer');
}



My page index.php return:
http://prntscr.com/gxnoht
Exclamation
Reply


Messages In This Thread
I can't make a news system - by Fayga - 10-14-2017, 06:02 PM
RE: I can't make a news system - by Fayga - 10-15-2017, 05:20 AM
RE: I can't make a news system - by ciadmin - 10-15-2017, 07:30 AM
RE: I can't make a news system - by Fayga - 10-15-2017, 12:48 PM
RE: I can't make a news system - by Fayga - 10-17-2017, 01:45 PM
RE: I can't make a news system - by zurtri - 10-17-2017, 03:23 PM
RE: I can't make a news system - by JeffreyB - 11-05-2017, 08:48 PM
RE: I can't make a news system - by ChicagoPhil - 11-05-2017, 09:38 PM
RE: I can't make a news system - by JeffreyB - 11-05-2017, 09:57 PM
RE: I can't make a news system - by ChicagoPhil - 11-05-2017, 10:48 PM
RE: I can't make a news system - by JeffreyB - 11-05-2017, 11:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB