SQL highscores

morsKarlfam

New Member
Ok, I have two MYSQL tables:\[code\]CREATE TABLE `sessions` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userID` int(11) NOT NULL, `runTime` int(11) NOT NULL, `monstersKilled` int(11) NOT NULL, `profit` int(11) NOT NULL, `tasks` int(11) NOT NULL, `xpGain` int(11) NOT NULL, `lastupdate` int(11) NOT NULL, PRIMARY KEY (`id`));\[/code\]And,\[code\]CREATE TABLE `users` ( `userid` int(11) NOT NULL AUTO_INCREMENT, `user` text NOT NULL, `pass` text NOT NULL, `paypal` text NOT NULL, `active` tinyint(1) NOT NULL DEFAULT '0', `strikes` int(11) NOT NULL DEFAULT '0', `session` text NOT NULL, `brand` text NOT NULL, `identifier` text NOT NULL, PRIMARY KEY (`userid`)) ENGINE=MyISAM AUTO_INCREMENT=651 DEFAULT CHARSET=latin1;\[/code\]As you can see, sessions has a link to the user's ID. Now I want to make a total high scores PHP file, but with my little knowledge of php and little knowledge of MYSQL I wouldn't know how to start. The total high scores would be sorted by Total runtime.Example:In users I have user #1 (cody) & user #2 (Joe). Now, In sessions I have 3 sessions:\[code\]id, userID, runTime, monstersKilled, profit, tasks, xpGain, lastupdate12, 1, 27, 14, 6200, 0, 5050, 128232541019, 1, 18, 1, 277, 1, 168, 12788977561968, 2, 195, 433, 111345, 4, 73606, 1280993244\[/code\]The print out should be along the lines of:\[code\]Place, username, Total Run Time, Total Monsters Killed, Total profit, Total tasks, Total Exp Gain1. Joe, 195, 433,11345,4,736062. Cody, 55, 15, 1, 5218\[/code\]
 
Back
Top