<?php

if(isset($_GET['mobile_no']) && $_GET['mobile_no']!=NULL && $_GET['operator']){
    $mobile_no = $_GET['mobile_no'];
    $operator = $_GET['operator'];

// $resultnew = file_get_contents("https://www.mplan.in/api/plans.php?apikey=e642133e3d12574ac7d10eef73ef3525&offer=roffer&tel=$mobile_no&operator=$operator");
$url = "https://www.mplan.in/api/plans.php?apikey=e642133e3d12574ac7d10eef73ef3525&offer=roffer&tel=$mobile_no&operator=$operator";
 $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    curl_close($ch);
$offers = json_decode($output);
// var_dump($offers);
$sstring ='';

$total_offers = count($offers->records);
$result = array();

  if($total_offers > 0){
    
         $result['error'] = "0";
          $result['error_msg'] = "Offers Fetched";
          $sstring = "<table class='table table-bordered table-striped' width='100%' padding='4' style='padding:10px;'>
                <tr>
                <th width='80%'>Description</th>
                <th width='10%'>Price</th>
                </tr>";
        for ($i = 0; $i < $total_offers; $i++) {
           $sstring .= "<tr onclick=select_plan('prepaid','" .$offers->records[$i]->rs . "')>"
                        . "<td>" .$offers->records[$i]->desc . "</td>"
                        . "<td><i class='fa fa-rupee-sign'></i> " .$offers->records[$i]->rs . "</td>"
                        . "</tr>";
        }
         $sstring .= "</table>";

    }else{
        $result['error'] = "1";
    }
     
    
     
// $result['plans'] = $sstring;
echo $sstring;


// echo json_encode($result);

}else{
echo "Select Operator or enter Proper Phone No";
}

?>


