Ok, I have two MYSQL tables:
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`)
);
And,
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;
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:
id, userID, runTime, monstersKilled, profit, tasks, xpGain, lastupdate
12, 1, 27, 14, 6200, 0, 5050, 1282325410
19, 1, 18, 1, 277, 1, 168, 1278897756
1968, 2, 195, 433, 111345, 4, 73606, 1280993244
The print out should be along the lines of:
Place, username, Total Run Time, Total Monsters Killed, Total profit, Total tasks, Total Exp Gain
1. Joe, 195, 433,11345,4,73606
2. Cody, 55, 15, 1, 5218