<?php
    include_once 'opendb.php';
    $filter="";
     $CompID=0;
      if (isset($_POST["comp_id"]))
    {
        $CompID=$_POST["comp_id"]; 
         $filter.=" where comp_id=" . $CompID;
    }
    if($CompID==0) {
        
         $response["message"] = "Error: Web Co ID invalid";
            // echo no users JSON
            die( json_encode($response));
    }
    $filter.=" and end_date >= CURDATE() ";
    $Qry="SELECT web_entry_no as offer_id,offer_code,offer_desc,start_date,end_date from web_offers ";
    $Qry.=$filter;
   // die($Qry);
    if ($result = mysqli_query ($conn,$Qry))
    {
      if (mysqli_num_rows($result) > 0)
      {
              $response = array();
              while ($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
              {
                  $request = array();

                  $request["offer_id"] = $row["offer_id"];
                  $request["offer_code"] = $row["offer_code"];
                  $request["offer_desc"] = $row["offer_desc"];
                  $request["start_date"] = $row["start_date"];
                  $request["end_date"] = $row["end_date"];
                  array_push($response, $request);
              }
              echo json_encode($response);
       } else
       {   
              $response["message"] = "NoData";
              echo json_encode($response);
       }
    }
   else {
        $response["message"] = "NoData";
              echo json_encode($response); 
  }
 $conn->close();
?>