<?php
    include_once 'opendb.php';
    $filter="";
     $CompID=0;
     $lastdate="";
    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));
    }
    if (isset($_POST["lastdate"]))
    {
        $lastdate=$_POST["lastdate"]; 
        $filter.=" and photo_edit_time > '$lastdate' ";
    }
    
    $Qry="SELECT prod_code,photo_edit_time  from products ";
    $Qry.=$filter . " order by photo_edit_time ";
   // 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["prod_code"] = $row["prod_code"];
                  $request["photo_edit_time"] = $row["photo_edit_time"];  
                  array_push($response, $request);
              }
              echo json_encode($response);
       } else
       {   
              $response["message"] = "NoData";
              echo json_encode($response);
       }
    }
   else {
        $response["message"] = "Error:".$Qry; 
              echo json_encode($response); 
  }
 $conn->close();
?>