简体   繁体   English

尝试向多个用户提供活动供稿,并对其进行订购

[英]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 我正在收集他们关注的人,如我的代码第6-20行所示
http://pastebin.com/556aRdWt 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. 最简单的方法是在查询中对它进行排序,然后MySQL将处理该问题。 This can be done with an ORDER BY clause. 这可以通过ORDER BY子句完成。 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. 如果您有created_on列,则最适合您的订购。

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'];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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