来自同一页面的2个查询不显示数据

时间:2014-03-14 03:17:17

标签: php mysql loops

    $t_enquirys_big_total = 0;
    for ($i=0; $i<$totaldept; $i++){

         $name = $v_ud_name[$i];

        $querytotal = "SELECT category, user_dept_name
                    FROM $t_bug_table
                    WHERE team_id = '$t_team' && user_dept_name = '$name' && date_submitted BETWEEN '$t_start_string2' AND '$t_end_string2'";

        $resulttotal = db_query ($querytotal);

        while ($rowtotal = db_fetch_array ($resulttotal)){

            $t_enquirys_big_total++;
        }
    }

    for ($i=0; $i<$totaldept; $i++){

         $name = $v_ud_name[$i];

        $querybug = "SELECT category, user_dept_name
                    FROM $bug_table
                    WHERE team_id = '$t_team' && user_dept_name = '$name' && date_submitted BETWEEN '$t_start_string2' AND '$t_end_string2'";

        $resultbug = db_query ($querybug);

        $t_enquirys_total = 0;

        $t_aenquirys = 0;
        $t_complaint = 0;
        $t_general = 0;
        $t_request = 0;
        $t_dailywork = 0;
        $t_enguiry_count[$v_det_id[$i]] = 0;
        $t_complaint_count[$v_det_id[$i]] = 0;
        $t_general_count[$v_det_id[$i]] = 0;
        $t_request_count[$v_det_id[$i]] = 0;
        $t_dailywork_count[$v_det_id[$i]] = 0;
        $t_aenquirys_total = 0;
        $t_complaint_total = 0;
        $t_general_total = 0;
        $t_request_total = 0;
        $t_dailywork_total = 0;
        $t_aenquirys_total_perc = 0;
        $t_complaint_total_perc = 0;
        $t_general_total_perc = 0;
        $t_request_total_perc = 0;
        $t_dailywork_total_perc = 0;

        $t_cat_total[$v_ud_id[$i]] = 0;
        $t_all_cat_total = 0;

        $t_enquiry_val = 'Enquiry';
        $t_complaint_val = 'Complaint';
        $t_general_val = 'General';
        $t_request_val = 'Request';
        $t_dailywork_val = 'Daily Work';

        while ($rowbug = db_fetch_array ($resultbug)){

            $t_enquirys_total++;

            switch( $rowbug['category'] ) {
                case $t_enquiry_val:
                    $t_aenquirys++;
                    $t_enguiry_count[$v_ud_id[$i]]++;
                    break;
                case $t_complaint_val:
                    $t_complaint++;
                    $t_complaint_count[$v_ud_id[$i]]++;
                    break;  
                case $t_general_val:
                    $t_general++;
                    $t_general_count[$v_ud_id[$i]]++;
                    break;
                case $t_request_val:
                    $t_request++;
                    $t_request_count[$v_ud_id[$i]]++;
                    break;
                case $t_dailywork_val:
                    $t_dailywork++;
                    $t_dailywork_count[$v_ud_id[$i]]++;
                    break;

                }

        }

    $t_cat_total[$v_ud_id[$i]] = $t_enguiry_count[$v_ud_id[$i]] + $t_complaint_count[$v_ud_id[$i]] + $t_general_count[$v_ud_id[$i]] + $t_request_count[$v_ud_id[$i]] + $t_dailywork_count[$v_ud_id[$i]];
    $t_ud_total_perc[$v_ud_id[$i]] = number_format((($t_cat_total[$v_ud_id[$i]] / $t_enquirys_big_total) * 100), 2);

这是我用来检索数据和计算百分比的函数的一半。当我尝试使用$ querytotal时,它确实打印出数据,但是它下面的第二个$ querytotal没有显示数据..请帮助

1 个答案:

答案 0 :(得分:0)

事情发生是因为我的执行时间是30秒。添加此特定代码后,它可以正常工作。ini_set("max_execution_time", 0);