CodeIgniter Forums
I can't make a news system - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: I can't make a news system (/showthread.php?tid=69159)

Pages: 1 2


I can't make a news system - Fayga - 10-14-2017

Hello
I come to you because I would like to make a site under CodeIgniter, but the concern is that I do not get the step to create a news system.
Please, can you give me a .zip containing this one system?
And also, how to make a registration system under this Framework?
Thanks, and soon!
PS: I am French in case


RE: [News] I can't make a news system - ciadmin - 10-14-2017

Hmmm - there is no "one news system" - not clear what you are looking for.
You might search the forum for similar sites, or the wiki, or even (shudder) google.


RE: I can't make a news system - Fayga - 10-15-2017

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


RE: I can't make a news system - ciadmin - 10-15-2017

You have SQL to create your table, in the middle of your PHP code. That's not going to work!


RE: I can't make a news system - Fayga - 10-15-2017

How to make a move?
Can you give the correction code?
Thank you, sir.


RE: I can't make a news system - Fayga - 10-17-2017

Help please


RE: I can't make a news system - zurtri - 10-17-2017

Sounds like a homework question....


RE: I can't make a news system - JeffreyB - 11-05-2017

As the man said - you have sql in your php files.

Remove this chunk:


Code:
CREATE TABLE news (
        id int(11) NOT NULL AUTO_INCREMENT,
        title varchar(128) NOT NULL,
        slug varchar(128) NOT NULL,
        text text NOT NULL,
        PRIMARY KEY (id),
        KEY slug (slug)
);

Hopefully I got the right stuff for you to dump. Run your files again. See if you get a different error message. Theoretically, you already have a database table because you ran the code like this once already someplace else -- maybe. In any event, that code should be used in your database management and is a one-time deal, creating your database table that will forever and ever be used by the rest of your code. How THAT database and the table within is managed depends on where you are hosted. If you are localhost, open your wamp. xampp whatever and look at your tables. If you are indeed already there and have it, go to work on the next issues. Best I can do since I don't really know too much but I was looking at other posts and thought I might try to help.


RE: I can't make a news system - ChicagoPhil - 11-05-2017

You did the right thing. When ever you run into a problem like this, here are the first steps to take:
1) Panic uncontrollably
2) Immediately make a post on the forum and let everyone know there is a PHP CODE FIRE.
3) Sit back and wait for the first responders to show up and fix it for you.

It's a good system. Tongue


RE: I can't make a news system - JeffreyB - 11-05-2017

(11-05-2017, 09:38 PM)ChicagoPhil Wrote: You did the right thing. When ever you run into a problem like this, here are the first steps to take:
1) Panic uncontrollably
2) Immediately make a post on the forum and let everyone know there is a PHP CODE FIRE.
3) Sit back and wait for the first responders to show up and fix it for you.

It's a good system.  Tongue

So, your point is?:

1) Tell us non-experts, of which I am unashamedly one, "Don't pitch in and try to help?"
2) Make fun of the the person asking for help?
3) Since the thread was dying, am I being accused of a PHP code fire, whatever that is??

Why is it that people who write code...which has to be EXACT...are ALWAYS saying and posting things that are difficult or impossible to understand? LOL.

If this was an attempt at humour, forgive me for not quite getting it. Let me know how I can improve myself please. I'm not trying to insult anybody, especially as I am brand new here. I really didn't understand your post. See the preceding paragraph.