图表php问题显示数据

时间:2013-12-15 20:11:26

标签: php mysql sql

我在图表上显示数据时遇到问题。当我尝试选择我的数据时会出现问题。这是代码:

    $sel_timestamp = mktime(0, 0, 0, date("n"), date("j")-$day, date("Y"));
    $sel_tag = date("Y.m.d",$sel_timestamp);
    mysql_connect(db_server, db_user, db_pass);
    $result = mysql_db_query(db_name,"SELECT *, COUNT(tracking.user_id) AS user_views FROM user, tracking WHERE tracking.user_id = $user_id AND tracking.timestamp = $les_tag GROUP BY $user_id ORDER BY user_views LIMIT 1");      
    $usercheck = mysql_result($res, 0, 0); 
    $Userstats = $usercheck;  

    $bar[$bar_nr]=$Userstats; 
    $bar_title[$bar_nr] = date("j.M.Y",$les_timestamp);

    if (date("j")-$day == 1) $bar_mark = $bar_nr;
    if ( date("w", $les_timestamp) == 6 OR date("w", $les_timestamp)== 0) {$weekend[$bar_nr]=true;}
    else {$weekend[$bar_nr]=false;}

    $bar_nr++;

数据显示为具有一个访问者的所有条形图。我相信问题发生在SELECT这里是代码:

    $result = mysql_db_query(db_name,"SELECT *, COUNT(tracking.user_id) AS user_views FROM user, tracking WHERE tracking.user_id = $user_id AND tracking.timestamp = $les_tag GROUP BY $user_id ORDER BY user_views LIMIT 1");      
    $usercheck = mysql_result($res, 0, 0); 
    $Userstats = $usercheck;  

如何修复代码,以便正确显示图表?

1 个答案:

答案 0 :(得分:0)

此查询功能已被弃用 http://www.php.net/function.mysql-db-query

您查询的另一个问题是您正在尝试对数据进行分组,但将查询结果限制为1(限制1)