<? header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
header("Allow: GET, POST, OPTIONS, PUT, DELETE");
$method = $_SERVER['REQUEST_METHOD'];
if($method == "OPTIONS") {
    die();
}



?>

{

	"notas":

[



<?


include 'url_amigable.php';
$cat = $_GET['cat'];
$c = (int)$_GET['c'];
if ($cat == '') {$cat = 0;};
if ($c == '') {$c = 0;};

include 'concha.php';

mysql_connect ("$host2", "$usuario2", "$contra2");
mysql_select_db ("$basedatos2");




$sql = "SELECT * FROM `notas` WHERE `notas`.`cat` = '$cat' ORDER BY `ID` DESC LIMIT $c,10";


$consulta = mysql_query ($sql);

$total_r = mysql_num_rows($consulta);
while ($row = mysql_fetch_array($consulta))
{


$ID = $row["ID"];
$ID_cancion = $row["ID"];
$titulo = $row["titulo"];
$bajada = $row["bajada"];
$foto = $row["foto"];
$carpetafoto = $row["carpetafoto"];
$img_ext = $row["ext_img"];
$dia = $row["d"];
$mes = $row["m"];
$ano = $row["a"];
$nn = $nn + 1;

$titulo = str_replace('"', "'", $titulo);
$bajada = str_replace('"', "'", $bajada);
$bajada = str_replace('<br />',' ', $bajada);
$bajada = json_encode($bajada);
        ?>

        {
            "id": "<?php echo $ID_cancion?>",
            "titulo": "<?php echo $titulo ?>",
            "bajada": <?php echo $bajada ?>,
            "fecha": "<? echo $dia;?>/<? echo $mes;?>/<? echo $ano;?>",
            "foto": "<? echo $dom;?>/<? echo $carpetafoto; ?>/resize_<? echo $foto ?><? echo $img_ext;?>"

        } <? if ($total_r == $nn) {} else {echo ',';} ?>



        <?



          }

          mysql_free_result($consulta);





?>]}
