I'm trying to make a list where the format goes as follows:
CLUB
CLUB 2
So far, I've managed to autogenerate tables but for each name it displays the name of the club above, even if it's the same club as another one above it. I've tried to do it through mysqli, I don't know if it would be better through PHP. Here's my query so far:
$sql = "SELECT DISTINCT soc.nombre, soc.apellido, club.nombreClub FROM socios as soc
INNER JOIN club4h as club
ON soc.nombreClub = club.nombreClub";
$result =NULL;
foreach($conn->query($sql) as $row){
$club[] = $row["nombreClub"];
$nombreSoc[] = $row["nombre"];
$apellidoSoc[] = $row["apellido"];
}
And here's how it's looking with that query:
You can just use order by statement in your SQL query
$sql = "SELECT DISTINCT soc.nombre, soc.apellido, club.nombreClub FROM
socios as soc
INNER JOIN club4h as club
ON soc.nombreClub = club.nombreClub
ORDER NY club.nombreClub DESC, soc.nombre DESC";
So this way you will get your data sorted out of the database and all you need to do is display it.