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

(This post was last modified: 10-14-2017, 09:32 PM by ciadmin.)

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
Exclamation
Reply
#2

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.
Reply
#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
#4

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

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

Help please
Exclamation
Reply
#7

Sounds like a homework question....
Reply
#8

(This post was last modified: 11-05-2017, 09:16 PM by JeffreyB. Edit Reason: trying to add clarity )

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.
Reply
#9

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
Reply
#10

(This post was last modified: 11-05-2017, 10:07 PM by JeffreyB. Edit Reason: always trying for clarity )

(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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB