<? 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");
header("Allow: GET");
$method = $_SERVER['REQUEST_METHOD'];
if($method == "OPTIONS") {
    die();
} ?>

{
	"usuarios":
[

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



include 'concha.php';
mysql_connect ("$host2", "$usuario2", "$contra2");
mysql_select_db ("$basedatos2");

if ($c == '' || $c == 0) {
    $sql = "SELECT * FROM `users_tienda` WHERE `nombre` != '' ORDER BY `ID` desc";
    
} else {
    $sql = "SELECT * FROM `users_tienda` WHERE `ID` = '$c' ORDER BY `ID` desc";
}
$consulta = mysql_query ($sql);
$total_r = mysql_num_rows($consulta);
while ($row = mysql_fetch_array($consulta))
{

$ID2 = $row["ID"];
$email = $row["email"];
$nombre = $row["nombre"];
$apellido = $row["apellido"];
$telefono = $row["telefono"];
$direccion = $row["direccion"];
$localidad = $row["localidad"];
$provincia = $row["provincia"];
$cp = $row["cp"];
$nn = $nn + 1;
?>

        {
          "id": "<?php echo $ID2?>",
          "nombre": "<?php echo $nombre ?>",
          "apellido": "<?php echo $apellido ?>",
          "email": "<?php echo $email ?>",
          "telefono": "<?php echo $telefono ?>",
          "direccion": "<?php echo $direccion ?>",
          "localidad": "<?php echo $localidad ?>",
          "provincia": "<?php echo $provincia ?>",
          "cp": "<?php echo $cp ?>"
          
        } 
        <? if ($total_r == $nn) {} else {echo ',';} 
          } mysql_free_result($consulta);
        ?>
]
}
