I have 5 tables in database. Database is for statistics for football (soccer) players and its relational database.
One is for table is for player, second for club, thrid for season, fourth tables is for player stats, and fifth table is connecting club and season.
I done everything is working like perfect except one thing. I want to paste values from database on site. In example that I gonna give that is season 1923, and that season has 6 clubs in league. On bottom page I have part of page that I am going to show statisicts for players (first name, last name, apps and goals for that season). And its working but not how I want. Its echoing all players and I want to divide that players first to be first club and his players then second and his...etc to the 6. Something like this:
club.
CLUB 1
players from that club with statiscits for that season
CLUB 2
...
etc
How this can be done with PHP, or I must alter my sql query. I can retrieve id of Club and name of Club but its not working with If else?! This is php code
<?php
include('connect-mysql.php');
$sqlcom = "SELECT jos_players.firstName, jos_players.lastName,jos_players.playerpic, jos_playerstats.idClub, jos_playerstats.idSeason, jos_igraciDB_club.name, jos_playerstats.apps, jos_playerstats.goals, jos_players.idPlayer
FROM `jos_playerstats`
LEFT JOIN `jos_igraciDB_club` ON `jos_playerstats`.`idClub` = `jos_igraciDB_club`.`idClub`
LEFT JOIN `jos_igraciDB_season` ON `jos_playerstats`.`idSeason` = `jos_igraciDB_season`.`idSeason`
LEFT JOIN `jos_players` ON `jos_playerstats`.`idPlayer` = `jos_players`.`idPlayer`
ORDER BY CASE position
WHEN 'Vratar' THEN 1
WHEN 'Bek' THEN 2
WHEN 'Half' THEN 3
WHEN 'Navala' THEN 4
END";
$result = mysql_query($sqlcom);
while($row=mysql_fetch_assoc($result))
{
$fname = $row['firstName'];
$lname = $row['lastName'];
$nick = $row['nickName'];
$apps = $row['apps'];
$goals = $row['goals'];
$position = $row['position'];
$img = $row['playerpic'];
$idpl = $row['idPlayer'];
echo '{modal igraci/article/'.$idpl.'|width=500|height=400|title='.$lname.' '.$fname.'}'.$fname.' '.$lname.' ('.$apps.'/'.$goals.'){/modal} ';
}
?>