doumuyu0837 2017-03-04 06:43
浏览 9
已采纳

将每小时每日每月数据从sql拉到jquery图表

I'm about to build a jquery chart that involves median order income number of customer etc for each day.

At this moment if I try my chart I get like 500 customers from the year 2012-2017 which is the total and not moving linearly to what I would like to.

What I want to make is that I get 0 - > 500 customers.

Could I loop these query or something to get data from all span and pull the number of customers so my data table shows, the neat line in the Jquery data-table?

Any pointers would be appreciated. I'm rather a novice on this kind of "advanced" MySQL queries

    $from_date = strtotime($fDay.date('F',mktime(0,0,0,$fMonth,15,2006)).$fYear);
    $to_date = strtotime($tDay.date('F',mktime(0,0,0,$tMonth,15,2006)).$tYear);

    $from_datetime = date_create(date("Y-m-d", $from_date));
    $to_datetime = date_create(date("Y-m-d", $to_date));

    //Statistikvariabler
    $all_orders = $DBcon->query("SELECT * FROM `order_structure` WHERE `date`>={$from_date} && `date`<={$to_date}");
    //Räkna ut totalsumma från och med nyår
    $all_orders_sum = $DBcon->query("SELECT * FROM `order_structure` WHERE `date`>={$from_date} && `date`<={$to_date}");
    $all_sum = 0;
    //Använd ovanstående för att räkna ut snittorder
    while($sum = $all_orders->fetch_assoc() ){
        $all_sum += $sum['sum'];
    }

    //Räkna ut debiterade timmar
    $all_orders_debs = $DBcon->query("SELECT * FROM `order_data` WHERE (`status`=3 || `status`=4) && `date`>={$from_date} && `date`<={$to_date}");
    $all_time = 0;
    $all_prods = 0;
    while( $debs = $all_orders_debs->fetch_assoc() ){
        $all_time += $debs['minutes'];
        $all_prods += $debs['sek'];
    }
  • 写回答

1条回答 默认 最新

  • dongyudun6465 2017-03-05 11:31
    关注

    Got it to work, was as I tought i needed to loop the data this is what I've got going at the moment.

      var e = {
        element: "areachart",
        behaveLikeLine: !1,
                parseTime: false,
        data: [
                    <?php while($jsfix = $jstemp->fetch_array() ) { ?>
    
                    {
                        x: '<?php echo $date = date('d-m-Y H:i:s', $jsfix['date']);?>',
                      s: '<?php echo $jsfix['sum'];?>',
    
                },
                <?php } ?>],
        xkey: "x",
        ykeys: ["s",],
        labels: ["Inkomst",],
        lineColors: ["#f9c1c1", "#c1daf9", "#3498db", "#2c3e50", "#1abc9c", "#34495e", "#9b59b6", "#e74c3c"]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 hexo+github部署博客
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了
  • ¥100 H5网页如何调用微信扫一扫功能?