0

2つのwhileループを使用してデータベースから2つの配列を取得しています。

while($row2 = mysql_fetch_assoc($result2))
    {
        $surveyscnt[$row2['user_grp_id']]=$row2['COUNT( * )'];
    }

    while($row3 = mysql_fetch_assoc($result3))
    {
        $ndhcnt[$row3['group_id']]=$row3['headcount'];
    }

foreachループ内で次のことを行う方法を誰かに教えてもらえますか

以下のforeachループを参照してください

    foreach($surveyscnt as $node => $headcount){
            if($ndhcnt[$node]!=$headcount){             
                $pIdsNself = getAllParentsNself(array(**NEED TO CALL group_id**));
                updateRollups($pIdsNself,**NEED TO PUT THE DIFFERENCE of(COUNT*-headcount)** );
            }
    }

どんな種類の助けもありがたいです

4

1 に答える 1

0

Try this, let me know if any issue.

  1. In your sql query put COUNT( * ) AS cnt and in while you fetch it like : $surveyscnt[$row2['user_grp_id']]=$row2['cnt'];

  2. $pIdsNself = getAllParentsNself(array(**NEED TO CALL group_id**)); Here $node is your group id(as per your coding) so change the line to getAllParentsNself(array($node));

  3. updateRollups($pIdsNself,**NEED TO PUT THE DIFFERENCE of(COUNT*-headcount)** );, Here you have both count* and head count so thi line will be updateRollups($pIdsNself,($headcount-$ndhcnt[$node]) );

于 2013-03-07T05:00:30.067 に答える