- How would I join and order these tables?
- `$query = mysql_query("SELECT u.* FROM friends uf inner join users u on uf.friend = u.username WHERE uf.user = '$user'") or die(mysql_error());
- WHILE($row = mysql_fetch_array($query)){
- $friends = $row['username'];
- $xptype = findType($table)."xp";
- $sql = mysql_query("SELECT * FROM skills WHERE playerName LIKE '$friends'") or die(mysql_error());
- while($rows = mysql_fetch_array($sql)){
- $rank = findRank($friends, "$table");
- echo '
- <div class="tableContainer cssTableSmall">
- <div class="hiscoresBoxTopLeft"></div>
- <div class="hiscoresBoxTopRight"></div>
- <div class="tableInnerContainer">
- <div class="header">
- <span class="columnRank">Rank</span>
- <span class="columnName">
- <span>Name</span>
- </span>
- <span class="columnLevel">
- <span>Level</span>
- </span>
- <span class="columnXp">
- <span>XP</span>
- </span>
- </div>
- <a name="'.$rank.'"></a>
- <a href="compare.php?user1='.$friends.'" target="_self" class="row ">
- <span class="columnRank">
- <span>'.$rank.'</span>
- </span>
- <span class="columnName">
- <span>'.BBCode($friends).'</span>
- </span>
- <span class="columnLevel">
- <span>'.getLevelForXP($rows[$xptype]).'</span>
- </span>
- <span class="columnXp">
- <span>'.dots($rows[$xptype]).'</span>
- </span>
- </a>
- ';
- }
- } `
- `CREATE TABLE IF NOT EXISTS `skills` (
- `playerName` varchar(15) NOT NULL DEFAULT '',
- `Attacklvl` double DEFAULT NULL,
- `Attackxp` double DEFAULT NULL,
- `Defencelvl` double DEFAULT NULL,
- `Defencexp` double DEFAULT NULL,
- `Strengthlvl` double DEFAULT NULL,
- `Strengthxp` double DEFAULT NULL,
- `Constitutionlvl` double DEFAULT NULL,
- `Constitutionxp` double DEFAULT NULL,
- `Rangelvl` double DEFAULT NULL,
- `Rangexp` double DEFAULT NULL,
- `Prayerlvl` double DEFAULT NULL,
- `Prayerxp` double DEFAULT NULL,
- `Magiclvl` double DEFAULT NULL,
- `Magicxp` double DEFAULT NULL,
- `Cookinglvl` double DEFAULT NULL,
- `Cookingxp` double DEFAULT NULL,
- `Woodcuttinglvl` double DEFAULT NULL,
- `Woodcuttingxp` double DEFAULT NULL,
- `Fletchinglvl` double DEFAULT NULL,
- `Fletchingxp` double DEFAULT NULL,
- `Fishinglvl` double DEFAULT NULL,
- `Fishingxp` double DEFAULT NULL,
- `Firemakinglvl` double DEFAULT NULL,
- `Firemakingxp` double DEFAULT NULL,
- `Craftinglvl` double DEFAULT NULL,
- `Craftingxp` double DEFAULT NULL,
- `Smithinglvl` double DEFAULT NULL,
- `Smithingxp` double DEFAULT NULL,
- `Mininglvl` double DEFAULT NULL,
- `Miningxp` double DEFAULT NULL,
- `Herblorelvl` double DEFAULT NULL,
- `Herblorexp` double DEFAULT NULL,
- `Agilitylvl` double DEFAULT NULL,
- `Agilityxp` double DEFAULT NULL,
- `Thievinglvl` double DEFAULT NULL,
- `Thievingxp` double DEFAULT NULL,
- `Slayerlvl` double DEFAULT NULL,
- `Slayerxp` double DEFAULT NULL,
- `Farminglvl` double DEFAULT NULL,
- `Farmingxp` double DEFAULT NULL,
- `Runecraftlvl` double DEFAULT NULL,
- `Runecraftxp` double DEFAULT NULL,
- `Hunterlvl` double DEFAULT NULL,
- `Hunterxp` double DEFAULT NULL,
- `Constructionlvl` double DEFAULT NULL,
- `Constructionxp` double DEFAULT NULL,
- `Summoninglvl` double DEFAULT NULL,
- `Summoningxp` double DEFAULT NULL,
- `Dungeoneeringlvl` double DEFAULT NULL,
- `Dungeoneeringxp` double DEFAULT NULL,
- PRIMARY KEY (`playerName`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
- CREATE TABLE IF NOT EXISTS `skillsoverall` (
- `playerName` varchar(15) NOT NULL DEFAULT '',
- `lvl` int(11) DEFAULT NULL,
- `xp` bigint(32) DEFAULT NULL,
- PRIMARY KEY (`playerName`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
- CREATE TABLE IF NOT EXISTS `users` (
- `username` varchar(255) NOT NULL DEFAULT '',
- `password` varchar(255) DEFAULT NULL,
- `rights` varchar(255) DEFAULT NULL,
- `friends` text,
- PRIMARY KEY (`username`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
- CREATE TABLE IF NOT EXISTS `friends` (
- `user` varchar(32) NOT NULL,
- `friend` varchar(32) NOT NULL
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1;`