I guess you get downvotes because your whole php code-block is unnecessary as far I can see. Your query "$qry2" is incorrect; you can't sum without a group by (unless you only do a sum). eg:
select dv_id, sum(net) as sum_net from tbl_dv group by dv_id