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

// Seleccionamos a los usuarios que tengan al menos una red social puesta
$sql = "SELECT name, picture_url, fb_url, ig_url, tt_url 
        FROM users 
        WHERE fb_url != '' OR ig_url != '' OR tt_url != '' 
        ORDER BY name ASC";

$result = $conn->query($sql);
$users = [];

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

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