[MySQL]Selecting multiple rows' info
#1

I got in problem to select multiple row' info from MySQL. I need to get Top 5 players' names and score but my Query get's only the first one.

pawn Код:
query("SELECT `Username`,`Score` FROM `Users` ORDER BY `Users`.`Score` DESC LIMIT 0, 5");
Anyone have any idea?
Reply
#2

pawn Код:
query("SELECT `Username`,`Score` FROM `Users` ORDER BY `Score` DESC LIMIT 5");
Try that?
Reply
#3

Nope, doesn't work.
Reply
#4

The query Hiddos gave you should be correct, try sending that query in phpmyadmin and see the result.
Reply
#5

It returns in phpMyAdmin but when I query it from ingame in mysql_debug file I see it only returned First player. I will try once again. Then we will see.
Reply
#6

You are not fetching the rows in a loop then. The retrieval functions can only work one row at a time.
Reply
#7

Can you give me example then?
Reply
#8

pawn Код:
new result[128],
    idx;
mysql_query("SELECT * FROM table");
mysql_store_result();
while(mysql_fetch_row_format(result) == 1)
{  
    sscanf(result, "p<|>dddd", id, food, salt, spoon);
    Array[idx] = food;
    idx++;
}
mysql_free_result();
Reply
#9

Ok. It works. Thanks Guys
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)