• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Some Advise?

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

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

#3
(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();

Reply

#4
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.
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.