php - CodeIgniter limit posts per page -


I am creating a blog, my homepage shows those posts coming from the database. I want to limit posts to one page and want to create a link below to get the next post. Please tell someone how to do this with some examples.

Thank you.

Controller code

  & lt; Php class MySite CI_Controller {function index () {$ this- & gt; Load-> Model ('posts_model'); $ Data ['result'] = $ this- & gt; Posts_model- & gt; GetAll (); $ This- & gt; Load-> Assistant ('html'); $ This- & gt; Load-> ("Title") view; $ This- & gt; Load-> ($ Data "home") view; $ This- & gt; Load-> ("Footer") scene; }? & Gt;  

Model code

  & lt ;? Expand Php class post_model CI_Model {public function getAll () {$ this- & gt; Load-> Database (); $ Query = $ this- & gt; Db- & gt; Receive ('post'); Return $ query- & gt; result (); }}  

?

View code

  & lt ;? Php foreach ($ result as line $) {$ a_url = "mysite / single /".$ row-> Id; Echo "& lt; div id =". "'Postdiv'". "& Gt;"; Echo "& lt; h1 & gt;". Anchor ($ a_url, $ Row-> Title). "& Lt; / h1>"; Echo "& lt; p & gt;" $ Line-> material. & Lt; / P & gt; "; Echo" & lt; P & gt; Posted by: "line-> author." & Lt; / P & gt; "; echo" & lt; Br> "; echo" & lt; / Div> ";}? & Gt;  

Here's a good blog Which shows load and paging using jquery and codeigniter.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -