<?php
header('Content-Type: application/json');

// Credenciales de conexión
$servername = "localhost";
$username = "farmacia_onlydi2025";
$password = "1corintios13";
$database = "farmacia_sufarma2025";

// Conexión a la base de datos
$conn = new mysqli($servername, $username, $password, $database);
if ($conn->connect_error) {
    die(json_encode(['error' => 'Error de conexión: ' . $conn->connect_error]));
}

$sql = "SELECT id, nombre FROM sucursales";
$result = $conn->query($sql);

$branches = [];
while ($row = $result->fetch_assoc()) {
    $branches[] = $row;
}

echo json_encode($branches);
$conn->close();
?>
