I am trying to retrieve the games from a certain catigory in my arcade site so it displays 10 arcade games from each catigory. Below is my mySQL: And to make it easier for someone to help me, this is what I am currently using to get back the top 10 played games, what I want is for it to display 10 games from catigory "Movies" in the order of most played so here is the php code im using: I hope I wasnt confusing thank you in advance for reading this and help would be greatly appriciated.
I've been playing around the whole time since I posted, but still keep getting mySQL errors, I still at start ;( Any help is greatly appriciated
To make your code more portable and easier to manage you may want to check out PEAR and its DB-package. hxxp://pear.php.net/package/DB
First off, thanks for the response I colored red the important stuff for people in a rush because I wrote a bit. I don't want to make it complicated, the script I am using writes everything into a mySQL and I know all that needs to be change is something small. The script I want is so that it retrieves from catigory movies in order of times played, I don't think that you have to modify the current script that much (it already has ordering in order of times played) but maybe I'm wrong. Does anyone know what I should change in my code above (the second one) to make it so that it retrieves not only the top games played, but also - Games from catigory Movies - In order of most played (which is already done in second script) - Listing only top 10 (which is already done) I've been having a lot of trouble and I know most people here know what a pain it is to be stuck on the same thing for 2 days. Any help is greatfully appriciated.
Do you connect to the database and select the correct database? mysql_connect("localhost", "user", "password"); mysql_select_db("database");
First off, thanks again for your response. Yeah, I have no problem with code I currently use, it retrieves list of top 10 played games just fine and shows them, I just want to know what I should add to that code so that it shows the top 10 games played from the "Movie" catigory in the mySQL database. Sorry if I was confusing at first, any help is greatly appriciated, thanks.
Try something like this.... <p><font size="1"> <? $sql2 = "SELECT * FROM games where catagory LIKE movies ORDER BY played DESC LIMIT 0,10"; $result2 = mysql_query($sql2); while($row2 = mysql_fetch_array($result2)) { ?> <a href="game.php?gameid=<? echo $row2["gameid"]; ?>"> <? echo $row2["name"]; ?> </a><br> <? } ?> <? $sql2 = "SELECT * FROM games"; $result2 = mysql_query($sql2); $totalplayed = 0; while($row2 = mysql_fetch_array($result2)) { $totalplayed = $totalplayed+$row2["played"]; } ?></font></p></div>
Thanks livingearth but it didnt work i got this error and that's after i changed catagory to category in the script you posted Any help is greatly appricited, if you see whats wrong please point it out, thanks in advance.
thanks for your reply I can't be sure because I am using php include, but could look that code over, I fixed the spelling of category and made movies Movies, but something is still wrong in that. any help is appriciated, thanks in advance.
I got it guys Answers at: http://www.codingforums.com/showthread.php?p=406777&posted=1#post406777 incase your all interested