4 and is_active=1 and tpp.id=tpep.PAYPERIOD_ID and COMPONENT_ID=21 and tpep.EMPLOYEEID=wm.eb_id order by eb_no "; $tamt=0; $resulta = $conn->query($sql); while($rowa = $resulta->fetch_assoc()) { // $cmpn=$rowa["company_id"]; echo $rowa["Employee Code"]; $tamt=$tamt+$rowa["Net_Pay"]; } echo $tamt;