<?php
$dt=sites();
echo json_encode($dt);

function sites(){
  global $ar,$db;
  $dt=array();


  $sql="SELECT a.site_id as id,b.title,b.icon_url,count(*) as count from gnews_item a JOIN gnews b ON a.site_id=b.id where a.st>0 and a.st_body=2 and a.title!='' and char_length(a.img)>40 group by site_id order by b.title";
  //$dt['sql'][1]=$sql;
  $res=mysqli_query($db,$sql);
  if(mysqli_num_rows($res)>0){
    $dt['success']=true;
    $dt['get_at']=date("Y-m-d H:i:s");
    $dt['count']=mysqli_num_rows($res); 
    $a=0;
    while($r=mysqli_fetch_assoc($res)) {
      $dt['data'][$a]=$r;
      $dt['data'][$a]['select']=0;
$a++;   
    }
  } else {
    $dt['error']=true;
    $dt['message']="Data not found";        
  }
  return $dt;
  $db->close();
}
?>
/home/u1731472/public_html/
sub/cpapp_ekbis/api/v2/php/sites.php