<?php
require_once('dbcon.php');
$user_id = $_POST['user_id'];
$airtime = $_POST['airtime'];
$grupid = $_POST['grupid'];

$amount = (int)$airtime;


$c = mysql_query("select * from airtime_contacts where customer_id = '$user_id' and group_id = '$grupid' ");
$nums = mysql_num_rows($c);

$rows = array();
while($r = mysql_fetch_assoc($c)) {
    $rows[] = $r;
}


$total_amount =  $amount * $nums;

$user['total_amount'] = $total_amount;
$user['airtime'] = $airtime;
$user['user_id'] = $user_id;
$user['grupid'] = $grupid;
$user['amount'] = $amount;
$user['records'] = $rows;
echo json_encode($user);
//return $user;

?>