简体   繁体   中英

Attempting activity feed with multiiple users and for it to be ordered

Firstly, what i am trying to do is have a page that users can see that will have updates via people they are following. I am collecting the people they are following as shown in my code on lines 6-20
http://pastebin.com/556aRdWt
Then i continue to find and display the activity(s) that are found for each user inside an array. Now the trouble i am having is that i am trying to make it display the most recent additions first. But i am having trouble trying to sort the array.I tried to attempt this on my own but i am falling at the last hurdle. If you have any suggestions or comments please don't be afraid to ask, also if you need anymore information let me know.

Thank you for your time.

The easiest way is to sort it in your query and MySQL will handle that. This can be done with an ORDER BY clause. Without knowing your database columns, I can't recommend an exact query. If you have a created_on column, that would be best for your ordering.

Just as a side note, this is not how you add elements to an array:

$following[] .= $row['follow_id'];

Try this this instead:

$following[] = $row['follow_id'];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM