php - Codeigniter: Single Post is Not Shown -


I am trying to create a simple blog with the knowledge of an elementary Knowledge Base. I've been able to loop all the blog posts in the index page but when I try to open a single post that does not appear. Although things seem right to me I

Model:

  function get_post ($ postID) {$ this- & gt; Db- & gt; () - & gt; From ('post') - & gt; Where (array ('active' => 1, 'postID' = & gt; 'Post id')) - & gt; Order-B ('date_added', 'desc'); $ Query = $ this- & gt; Db- & gt; get receive (); $ Query- & gt; Return First_RO ('array'); }  

Controller:

  Function post ($ postID) {$ data ['post'] = $ this- & gt; Post- & gt; Get_post $ postid); $ This- & gt; Load-> View ('Post', $ data); }  

See:

   

The single page "This is used incorrectly" shows the blog link here.

This is probably in "typo":

  $ data [ 'Post'] = $ this- & gt; Post- & gt; Get_post ($ postID);  

Here you use Post (many) and then you try to access it with $ post Then just replace it:

  $ data ['post'] = $ this- & gt; Post- & gt; Get_post ($ postID);  

and it should be fixed


UPDATE

In addition to models You have:

  $ this-> Db- & gt; Select () - & gt; From ('post') - & gt; Where (array ('active' => 1, 'post id' = & gt; 'post id')) - & gt; Order-B ('date_added', 'desc');  

Where are you going to 'postID' = & gt; 'Post id' The second part should be the variable $ postID :

  $ this-> db- & gt; Select () - & gt; From ('Post') - & gt; Where (array ('active' => 1, 'postID' = & gt; $ postID)) - & gt; Order-B ('date_added', 'desc');  

Comments