Jump to content


Photo

I want to select the highest scores from a database


  • Please log in to reply
10 replies to this topic

#1 Rosst

Rosst
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 05 October 2006 - 02:01 AM

I want to select the highest scores from a database, it's from a PHP/MySQL/Flash snake game, see here: http://vexxon.net/index.php? the bottom right content thingy has the snake high scores, but it's not in order, how would I put them in order?
Thanks in advance for the help.

#2 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 05 October 2006 - 02:06 AM

Using SQL order by. 
SELECT * FROM high_scores ORDER BY score DESC LIMIT 5


#3 Rosst

Rosst
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 05 October 2006 - 02:23 AM

I use the same thing, it doesn't work, except I have asc instead on desc
<?php
include("config.php");
$a = mysql_query("select * from snake order by score asc limit 5");
while ($b = mysql_fetch_array($a)) {
echo "<a href=\"index.php?id=memb&user=".$b[uname]."\">".$b[uname]."</a> - ".$b[score]."<br />";
}
if ($logged[username]) {
echo "Play snake: <a href=\"snake/snake.swf\">Link</a>";
}
?>


#4 markbett

markbett
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 05 October 2006 - 02:24 AM

you are using ASC dont you want DESC

#5 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 05 October 2006 - 02:25 AM

I'm sorry, it's limit 0,5

You would probably want the top scores in descending order.  That is how most video games do it.

1.  Player 1    50,000
2.  Player 2    40,000
3.  Player 3    30,000
4.  Player 4    20,000
5.  Player 5    10,000

#6 Rosst

Rosst
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 05 October 2006 - 02:32 AM

It is in descending order right now, and it doesn't look like it should, none of you are helping me!

#7 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 05 October 2006 - 02:47 AM

I assure you we are trying.  You can hardly get mad at free help.  What is the problem?

#8 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 05 October 2006 - 02:51 AM

What is the data type of the field containing the score?

#9 markbett

markbett
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 05 October 2006 - 04:12 AM

lol the irony that you have PHP tutorials on your site... well that and your flash logo is illegable...

just so you know descending means it starts big and gets small at this very moment the list isnt in desc order....  furthermore you will need to explain WHAT is not working... saying ITS NOT WORKING will do no good and is the reason why "none of (us) are helping you"

#10 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 05 October 2006 - 04:17 AM

I think he has DESC but has a string data type, so they are all equal, and displaying in the order they were entered into the database.

#11 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 05 October 2006 - 04:28 AM

Just so you know, using plain text as a CAPTCHA doesn't secure it at all, because anyone who was automating the registration process (presumably what you are trying to avoid, or does it just look cool?) could easily read that text from the page with a computer.  That is the idea behind CAPTCHA:  Completely Automated Public Turing test to tell Computers and Humans Apart. 

Check this:

http://evolt.org/sec...ms_random_image




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users