$city_name = $cafe_details->getCityName($row['city']); $city_url = '<a href="city_details.php?city_id=' . $row['city'] . '">View</a>'; //getting cafeid of the corresponding city $result_cafe = $cafe_details->getCafeIdByCityId($row['city']); //reset to counter zero $screen_count_act = 0; $screen_count_reg = 0; $today_count = 0; $day1_count = 0; $day2_count = 0; $day3_count = 0; $day4_count = 0; while ($row = mysql_fetch_array($result_cafe)) { $cafe_user_id = $cafe_details->getCafeUIDByCafeId($row['id']); if ($cafe_user_id) { $reg_terminals = $cafe_details->getScreenReg($row['id']); $screen_count_reg = $screen_count_reg + intval($reg_terminals); $caf_scr_act = $cafe_details->getCafeScreensCount($cafe_user_id); $screen_count_act = $screen_count_act + $caf_scr_act; $today_count = $today_count + $cafe_trac->getLiveScrCountTodayByCafeUID($cafe_user_id); $day1_count = $day1_count + $cafe_trac->getLiveScrCountByCafeUID($cafe_user_id, $day1); $day2_count = $day2_count + $cafe_trac->getLiveScrCountByCafeUID($cafe_user_id, $day2); $day3_count = $day3_count + $cafe_trac->getLiveScrCountByCafeUID($cafe_user_id, $day3); $day4_count = $day4_count + $cafe_trac->getLiveScrCountByCafeUID($cafe_user_id, $day4); } } echo '<tr>'; echo '<td>' . $city_name . '</td>'; echo '<td>' . $screen_count_reg . '</td>'; echo '<td>' . $screen_count_act . '</td>'; echo '<td>' . $day4_count . '</td>';