Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 8th, 2012  |  syntax: None  |  size: 4.49 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How would I join and order these tables?
  2. `$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());
  3. WHILE($row = mysql_fetch_array($query)){
  4.     $friends = $row['username'];
  5.     $xptype = findType($table)."xp";
  6.     $sql = mysql_query("SELECT * FROM skills WHERE playerName LIKE '$friends'") or die(mysql_error());
  7.     while($rows = mysql_fetch_array($sql)){
  8.         $rank = findRank($friends, "$table");
  9.             echo '
  10.                 <div class="tableContainer cssTableSmall">
  11.                 <div class="hiscoresBoxTopLeft"></div>
  12.                 <div class="hiscoresBoxTopRight"></div>
  13.                 <div class="tableInnerContainer">
  14.                 <div class="header">
  15.                 <span class="columnRank">Rank</span>
  16.                 <span class="columnName">
  17.                 <span>Name</span>
  18.                 </span>
  19.                 <span class="columnLevel">
  20.                 <span>Level</span>
  21.                 </span>
  22.                 <span class="columnXp">
  23.                 <span>XP</span>
  24.                 </span>
  25.                 </div>
  26.                 <a name="'.$rank.'"></a>
  27.                 <a href="compare.php?user1='.$friends.'" target="_self" class="row ">
  28.                 <span class="columnRank">
  29.                 <span>'.$rank.'</span>
  30.                 </span>
  31.                 <span class="columnName">
  32.                 <span>'.BBCode($friends).'</span>
  33.                 </span>
  34.                 <span class="columnLevel">
  35.                 <span>'.getLevelForXP($rows[$xptype]).'</span>
  36.                 </span>
  37.                 <span class="columnXp">
  38.                 <span>'.dots($rows[$xptype]).'</span>
  39.                 </span>
  40.                 </a>
  41.              ';
  42.     }
  43. } `
  44.        
  45. `CREATE TABLE IF NOT EXISTS `skills` (
  46.       `playerName` varchar(15) NOT NULL DEFAULT '',
  47.       `Attacklvl` double DEFAULT NULL,
  48.       `Attackxp` double DEFAULT NULL,
  49.       `Defencelvl` double DEFAULT NULL,
  50.       `Defencexp` double DEFAULT NULL,
  51.       `Strengthlvl` double DEFAULT NULL,
  52.       `Strengthxp` double DEFAULT NULL,
  53.       `Constitutionlvl` double DEFAULT NULL,
  54.       `Constitutionxp` double DEFAULT NULL,
  55.       `Rangelvl` double DEFAULT NULL,
  56.       `Rangexp` double DEFAULT NULL,
  57.       `Prayerlvl` double DEFAULT NULL,
  58.       `Prayerxp` double DEFAULT NULL,
  59.       `Magiclvl` double DEFAULT NULL,
  60.       `Magicxp` double DEFAULT NULL,
  61.       `Cookinglvl` double DEFAULT NULL,
  62.       `Cookingxp` double DEFAULT NULL,
  63.       `Woodcuttinglvl` double DEFAULT NULL,
  64.       `Woodcuttingxp` double DEFAULT NULL,
  65.       `Fletchinglvl` double DEFAULT NULL,
  66.       `Fletchingxp` double DEFAULT NULL,
  67.       `Fishinglvl` double DEFAULT NULL,
  68.       `Fishingxp` double DEFAULT NULL,
  69.       `Firemakinglvl` double DEFAULT NULL,
  70.       `Firemakingxp` double DEFAULT NULL,
  71.       `Craftinglvl` double DEFAULT NULL,
  72.       `Craftingxp` double DEFAULT NULL,
  73.       `Smithinglvl` double DEFAULT NULL,
  74.       `Smithingxp` double DEFAULT NULL,
  75.       `Mininglvl` double DEFAULT NULL,
  76.       `Miningxp` double DEFAULT NULL,
  77.       `Herblorelvl` double DEFAULT NULL,
  78.       `Herblorexp` double DEFAULT NULL,
  79.       `Agilitylvl` double DEFAULT NULL,
  80.       `Agilityxp` double DEFAULT NULL,
  81.       `Thievinglvl` double DEFAULT NULL,
  82.       `Thievingxp` double DEFAULT NULL,
  83.       `Slayerlvl` double DEFAULT NULL,
  84.       `Slayerxp` double DEFAULT NULL,
  85.       `Farminglvl` double DEFAULT NULL,
  86.       `Farmingxp` double DEFAULT NULL,
  87.       `Runecraftlvl` double DEFAULT NULL,
  88.       `Runecraftxp` double DEFAULT NULL,
  89.       `Hunterlvl` double DEFAULT NULL,
  90.       `Hunterxp` double DEFAULT NULL,
  91.       `Constructionlvl` double DEFAULT NULL,
  92.       `Constructionxp` double DEFAULT NULL,
  93.       `Summoninglvl` double DEFAULT NULL,
  94.       `Summoningxp` double DEFAULT NULL,
  95.       `Dungeoneeringlvl` double DEFAULT NULL,
  96.       `Dungeoneeringxp` double DEFAULT NULL,
  97.       PRIMARY KEY (`playerName`)
  98.     ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  99.  
  100.   CREATE TABLE IF NOT EXISTS `skillsoverall` (
  101.   `playerName` varchar(15) NOT NULL DEFAULT '',
  102.   `lvl` int(11) DEFAULT NULL,
  103.   `xp` bigint(32) DEFAULT NULL,
  104.   PRIMARY KEY (`playerName`)
  105. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  106. CREATE TABLE IF NOT EXISTS `users` (
  107.   `username` varchar(255) NOT NULL DEFAULT '',
  108.   `password` varchar(255) DEFAULT NULL,
  109.   `rights` varchar(255) DEFAULT NULL,
  110.   `friends` text,
  111.   PRIMARY KEY (`username`)
  112. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  113. CREATE TABLE IF NOT EXISTS `friends` (
  114.   `user` varchar(32) NOT NULL,
  115.   `friend` varchar(32) NOT NULL
  116. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;`