-1

こんにちは、あるループで 0 値を含む n/a 値を検索し、この値を別のループでカテゴリとともに送信したいと考えています。私のコードは

$i=0;   
$j=0;   
$newcount=$db->get_results("SELECT s2.qcategory, s1.id, count(s1.na) as na_count FROM (select distinct `qcategory` from store) s2  left join store s1  on  s1.`qcategory` = s2.`qcategory` and s1.survey_name='$userID' and s1.dateone='$dateVal' and s1.branch='$branch'  and s1.`na` = '1' group by 1 order by s1.id ");
    if($newcount)

    foreach($newcount as $sqcount)
    {
    $arval[$j]=$sqcount->na_count;
    $j++;   
    }

$newqcat=$db->get_results("SELECT count(id) as r_count, sum(point) as point_value,dateone, na, qcategory FROM store where survey_name='$userID' and dateone='$dateVal' and branch='$branch' group by qcategory order by id");

if($newqcat)
    {
    foreach($newqcat as $sqcat1)
            {
      echo  $sqcat1->qcategory?></a>
        $vv1=$arval[$i];
        $tcount_val1=$sqcat1->r_count-$vv1;
        $rowval=$sqcat1->qcategory;
        $per=($sqcat1->point_value*100)/($tcount_val1*5);
}

}

次のように、各カテゴリの適用外の値をカウントしたい

**First impression - 3
    Quality and value -0 
    Overall impression and ambiance - 1**

別のループで各 n/a 値を差し引きます

これを行う方法を教えてください。配列を使用してこれを試しましたが、正しく動作しません

4

1 に答える 1

1
$newqcat=$db->get_results("SELECT count(id) as r_count, sum(point) as point_value,dateone, na, qcategory FROM store where survey_name like '%$userID%' and dateone='$dateVal' and branch='$branch' group by qcategory order by id");
    if($newqcat)
    {
    foreach($newqcat as $sqcat1)
            {

    $newcount1=$db->get_row("SELECT s2.qcategory, s1.id, count(s1.na) as na_count FROM (select distinct `qcategory` from store where qcategory='$sqcat1->qcategory' and dateone='$dateVal' and branch='$branch') s2  left join store s1  on  s1.`qcategory` = s2.`qcategory` and s1.`na` = '1' and  s1.branch='$branch' and s1.dateone='$dateVal' and s1.survey_name='$userID' group by qcategory " );








$tcount_val1=$sqcat1->r_count-$newcount1->na_count;




    $rowval=$sqcat1->qcategory; 
    $per=($sqcat1->point_value*100)/($tcount_val1*5);
    echo "<td align=center valign=center>".round($per)."%</td></tr>";








}

}
于 2013-01-21T07:04:34.413 に答える