<?php
	$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
	$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
       
	$offset = ($page-1)*$rows;
	$result = array();

        /*echo '<script>
            var a="'.$offset.'"
            alert (a);
        </script>';
        */
        include("../../DMMYSQLG.php");
	
	$rs = mysqli_query($con ,"select count(*) from cusuario_grupo");
	$row = mysqli_fetch_row($rs);
        
	$result["total"] = $row[0];
        $consulta = "select dxopemaex_oper, cgrupo_id, oper.nombre as nombre_oper, grupo.nombre as nombre_grupo from dxopemaex as oper,cgrupo as grupo,cusuario_grupo as ug where ug.dxopemaex_oper=oper.oper and ug.cgrupo_id=grupo.id";
	//$original = "select * from cusuario_grupo order by cgrupo_id limit $offset,$rows";
        $rs = mysqli_query($con ,$consulta);
	 
	$items = array();
	while($row = mysqli_fetch_object($rs)){
		array_push($items, $row);
	}
	$result["rows"] = $items;

	echo json_encode($result);

?>