doucou19961205 2014-11-18 03:48
浏览 24

如何计算某个数据库表中的列+更多并在网站上显示(使用php)

I need my visitors on homepage to see how many active user we have. I need to include this with php. (need the code)

in mysql database user is marked with 0 (inactive) and 1 (active).

How can I count/read out the outcome, means all active users, of the database(database_name) - table(user_registration) - colums(each_one) - count(status)? How to publish this on my website?

Would prefer to this in php cause i'm not so used to js and query.

A simple methode/explanation would be very nice.

Thank you.

  • 写回答

3条回答 默认 最新

  • doufan9290 2014-11-18 03:58
    关注

    (need the code) first this is not a script writing service. Come up with some try and we will try giving a solution.

    Basic necessity for your required active user count is to have a status (or name it something) column in your user table.

    Then, while a user logs in change the status from 0 to 1 while logs out change it from 1 to 0

    by doing so you could easily query it to display the active user.

    select column,column from table where status = 1  
        //(i.e)
    select id,userName from users where status = 1
    

    Try using ajax if you want to display it like on-line users displayed in fb

    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器