<? 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();
} ?>

{
	"categorias":
[

<?
include 'url_amigable.php';
$c = (int)$_GET['c'];

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

include 'concha.php';
mysql_connect ("$host2", "$usuario2", "$contra2");
mysql_select_db ("$basedatos2");
$sql = "SELECT * FROM `categorias`";

$consulta = mysql_query ($sql);

$total_r = mysql_num_rows($consulta);

while ($row = mysql_fetch_array($consulta))
{


$ID = $row["ID"];
$color = $row["color"];
$nombre = $row["nombre"];
$nn = $nn + 1;
?>

        {
          "id": "<?php echo $ID?>",
          "color": "<?php echo $color ?>",
          "nombre": "<?php echo $nombre ?>"


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