I just started a game server and made a simple leaderboard on my website where it shows players stats. The problem I'm facing is that it will show duplicate rows in the table.
Here's what I mean:
And here is my code.
<?php
mysql_connect('','','') or die(mysql_error());
mysql_select_db('dbname') or die(mysql_error());
$query=mysql_query("select * from playerstats,playerinfo limit 0,10") or die(mysql_error());
echo'<table border="1" ><th >NOM DU JOEUR</th><th>VICTIMES</th><th>AI TUER</th><th>TEAMKILLS</th><th>DECES</th><th>RÉANIMATIONS</th><th>ARGENT</th>';
while($res=mysql_fetch_array($query))
{
echo'<tr><td>'.$res['Name'].'</td><td>'.$res['PlayerKills'].'</td><td>'.$res['AIKills'].'</td><td>'.$res['TeamKills'].'</td><td>'.$res['DeathCount'].'</td><td>'.$res['ReviveCount'].'</td><td>'.$res['BankMoney'].'</td></tr>';
}
echo'</table>';
?>
I would apreciate some help. I don't want duplicate entries if the username is already listed.
EDIT: Here is the 2 tables i am trying to fetch from
Here is the 2 tables i am trying to fetch from
-- -----------------------------------------------------
-- Table `PlayerStats`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `PlayerStats` (
`PlayerUID` VARCHAR(32) NOT NULL,
`LastModified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`PlayerKills` INT UNSIGNED NOT NULL DEFAULT 0,
`AIKills` INT UNSIGNED NOT NULL DEFAULT 0,
`TeamKills` INT UNSIGNED NOT NULL DEFAULT 0,
`DeathCount` INT UNSIGNED NOT NULL DEFAULT 0,
`ReviveCount` INT UNSIGNED NOT NULL DEFAULT 0,
`CaptureCount` INT UNSIGNED NOT NULL DEFAULT 0,
UNIQUE INDEX `idx_PlayerStats_uniquePlayer` (`PlayerUID` ASC),
CONSTRAINT `fk_PlayerStats_PlayerInfo`
FOREIGN KEY (`PlayerUID`)
REFERENCES `PlayerInfo` (`UID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `PlayerInfo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `PlayerInfo` (
`UID` VARCHAR(32) NOT NULL,
`CreationDate` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
`Name` VARCHAR(256) CHARACTER SET 'utf8' NULL,
`LastSide` VARCHAR(32) NULL,
`BankMoney` FLOAT NOT NULL DEFAULT 0,
`BattlEyeGUID` VARCHAR(32) NULL,
PRIMARY KEY (`UID`))
ENGINE = InnoDB;
