douewei1665 2013-10-08 23:03
浏览 29

如何动态显示用户配置文件?

This may very well have been asked before, but I could not find it.

I am building a page for users to browse other user's profiles. My current plan is for the profiles to be displayed in order of when they were last displayed and when they were last online.

So pretty much I give each item which resides in a database an attribute of last_displayed which contains a timestamp of when the profile was last displayed. Once a profile is displayed the timestamp will be updated and it will not be displayed until other profiles with older last_displayed timestamps are displayed.

At the same time there will be a last_online attribute which contains a timestamp of when the profile was last online. This is to show the more recently online users before showing the older users.

Now when actually querying the database for profiles to display I widen the range of last_displayed and last_online until sufficient profiles are found.

I assume this functionality is not unlike that of dating sites.

So my question is this: Is there a better way to dynamically display user profiles?

Thanks for reading if you got this far!

  • 写回答

1条回答 默认 最新

  • duan4739 2014-01-09 08:11
    关注

    Put a piece of SQL here or link to http://sqlfiddle.com/ — it's mostly about this.

    You must not use here any range wides — you should found some satisfactory column / order combination to have simple ORDER BY $columns LIMIT $num

    In this schema you can use in $columns something like: column1 DESC, column2 DESC or vice versa Or may be their combination like: IFNULL(column1, column2) or MAX(column1, column2).

    Go in this direction. When you found the right solution — publish it here.

    ps: I suggest you to remove here yii tag.

    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值