CodeIgniter Forums
Some Advise? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Some Advise? (/thread-1537.html)



Some Advise? - Riaanv - 03-19-2015

Hi i would like to know how i would go about getting all the newest posts from my users into one feed how would i achieve this in codeigniter? Basically i just want to select the latest post from each user in my database and display it in a feed like you would see on fb?

Just some help in the right direction would be greatly appreciated.


RE: Some Advise? - silentium - 03-19-2015

It sounds like you are new to CodeIgniter, welcome! I would recommend you start by reading the documentation.

Start with the CodeIgniter Overview and General Topics to get a over all understanding of how CodeIgniter works.

CodeIgniter is based on the MVC development pattern. In more detail, what you would need to do is to create a controller, a model and a view.
Place you database query in your model. You controller should execute the model function and then send the returned data to the view that will display the data.


RE: Some Advise? - rocks - 03-19-2015

(03-19-2015, 05:25 AM)Riaanv Wrote: Hi i would like to know how i would go about getting all the newest posts from my users into one feed how would i achieve this in codeigniter? Basically i just want to select the latest post from each user in my database and display it in a feed like you would see on fb?

Just some help in the right direction would be greatly appreciated.

All you need is a time column in your database, and fetch that table by order by time.

EX:

PHP Code:
function displayData(){
 
$this->db->from($this->table_name);
$this->db->order_by("time column"
$query $this->db->get(); 
return 
$query->result();




RE: Some Advise? - RobertSF - 03-20-2015

Yes, I agree that you should probably learn more about Codeigniter first. Your question is really a database question, not really related to Codeigniter. Are you also new to databases? You would need at least two table, one for your users and the other for your posts. Then you would join the two tables. You only want one post from every user, the very last post they made? In that case, your query would probably use the MAX() function to find the post with the highest date value for each user.