php - How do I retrieve the last 10 records from mysql database table? -


I have a strange problem when I run this script, I get 10 records from the database but they're all exactly the same. Are there. I do not know what I'm doing wrong or how to fix it. Please help me.

I want to see table AMCMS_highscores, AMCMS_users, AMCMS_games inside the AMCMS_highscores table, get the last 10 records, but only where the field game ID is 1997 for example. Any help is appreciated.

 select  $ data = Q ( "Kren` AMCMS_highscores`.`primkey`,` AMCMS_highscores`.`gameid`, `AMCMS_highscores`.`score`,` AMCMS_users`. `Username 'AMCMS_Hycomers``States, AMCMS_Highscores,' UserMess', 'AMCMS_Game'. 'Primki', 'AMCMSGame'. From Gammam 'AMCMS_Hauscocker', 'AMCMS_Game', 'AMCMS_UJs' where' AMCMS_ HighScore ' .`gameid` = '$ gameid' and `AMCMS_highscores`.`userkey`! =` AMCMS_users`.`userkey` and `AMCMS_highscores`.`gameid` =` AMCMS_games`.`primkey` and `` AMCMS_highscores`k`status AMCMS_ Aiscoras` Dwara` = "approved" orders. "Pramiki 'Diissi range 0, 10") of; Print "& lt; Table Range Cellpadding = 3" gt; "; While ($ info = mysql_fetch_array ($ data))" Print ""  "; Print" & lt; Th> ID: & lt; / Th & gt; & Lt; Td> "$ info ['userkey']." & Lt; / Td> & Lt; / Tr & gt; "Print; Print" & lt; / Table> ";  

Here is a format version of the query:

 select  'AMCMS_highscores`.`primkey`,` AMCMS_highscores` .`gameid`, `AMCMS_highscores`.` from score`, `AMCMS_users`.`username`,` AMCMS_highscores`.`status`, `AMCMS_highscores`.`userkey`,` AMCMS_games`.`primkey`, `` AMCMS_highscores` AMCMS_games`.`gamename`, `AMCMS_games` `AMCMS_users` where` AMCMS_highscores`.`gameid` = '$ gameid' and `AMCMS_highscores`.`userkey`! =` AMCMS_users`.`userkey` and `AMCMS_highscores`.`gameid `= 'AMCMS_games```primkey` and` AMCMS_highscores`.`status` =' AMCMS_highscores` by `command` Dynamic '' DISC limit 0, 'Approved' 10  

< P> Oh, I meant to copy that but I did not When it's "=" sign (highscores.userkey = users.userkey), I get a blank query so that it can not be corrected: (

I hope that this query Understanding would be easier :)