{ $db_connection = mysql_connect($this->db_server, $this->db_user, $this->db_password) or die(mysql_errno() . " - " . mysql_error() . "<br>"); if (mysql_select_db($this->db_name)) { if (!($result = mysql_query("SELECT DISTINCT `cafe_id` FROM `cafeactivation`"))) { print __CLASS__ . "::" . __FUNCTION__ . "()[" . __FILE__ . ":" . __LINE__ . "]: " . mysql_errno() . " - " . mysql_error() . "<br>"; } } else { print __CLASS__ . "::" . __FUNCTION__ . "()[" . __FILE__ . ":" . __LINE__ . "]: " . mysql_errno() . " - " . mysql_error() . "<br>"; } //$row_count = mysql_num_rows($result); return $result; mysql_close($db_connection); } } //creating objects $cafe_pay = new CafePay(); $cafe_details = new CafeDetails(); $result_cafe = $cafe_details->getAllActiveCafeIds(); while ($get_rows = mysql_fetch_array($result_cafe)) { $cafe_user_id = $get_rows['cafe_id']; $result = $cafe_details->getMacIdsByCafeUID($cafe_user_id); $amt = 0; while ($row = mysql_fetch_array($result)) { $mac_amt = 0; $mac_time = $cafe_pay->calcTimeOfMac($row['mac_id']); $mac_amt = $cafe_pay->calcAmountMac($cafe_user_id, $row['mac_id']); $amt = $amt + $mac_amt; $cafe_pay->insertPayMac($cafe_user_id, $row['mac_id'], $mac_time, $mac_amt); } $cafe_pay->insertPayCafe($cafe_user_id, $amt); }