<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Content-Type");
header("Access-Control-Allow-Methods: GET");
header('Access-Control-Max-Age: 86400');
header("Allow: GET");

$method = $_SERVER['REQUEST_METHOD'];

if($method == "OPTIONS") {
    die();
} 

include 'url_amigable.php';
$c = (int)$_GET['c'];
$cat = (int)$_GET['cat'];
$orden_var = 900;

if ($c == '') {$c = 0;};

include 'concha.php';

$table_name = 'notas';

$db_conn = mysqli_connect($host, $usuario, $contra) or die('Error: Could not connect.');
mysqli_select_db($db_conn, $basedatos) or die('Error: Could not select database.');
$result = mysqli_query($db_conn, "SELECT * from " . $table_name . " WHERE destacado = 'no' AND ver = 'si' AND home = 'si' and des_cat = 0 ORDER BY ID desc LIMIT $c,10") or die('Error: Could not query.');


$json = array();
if (mysqli_num_rows($result)) {
  while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
    $json['data'][] = $row;
  }
}

// for debug
//echo json_encode($json, JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT);

// for production
echo json_encode($json, JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT);

mysqli_close($db_conn);

?>

