doushi4795 2013-07-01 03:06
浏览 58
已采纳

PHP基于时间拆分数组值

I want this human readable words into php code:

Take all values from column "Ratings" WHERE Time >= 24 hours Split them into 1 hour each Take average Rating values for each hour and put them into 24 variables

WhatI'm doing now is a bad long code :/

I'm taking them an hour after another, each one in a separate function where I specify an hour via mysql select statement!

I'm new in programming, and I couldn't figure out what to do to get all values at once, and split them into 1 hour each

Thanks

  • 写回答

2条回答 默认 最新

  • dongyou2279 2013-07-01 03:18
    关注

    EDIT: changed the fiddle, so it uses time as an int, that represents seconds since January 1st, 1970.

    Take a look at this fiddle: http://sqlfiddle.com/#!2/6e6b6/5/0 It is returning the rating average on a hourly basis. Is this that you need? I think you might tune the query for your other needs.

    You can read more about it at http://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器