SA-MP Forums Archive
[MySQL]Selecting multiple rows' info - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [MySQL]Selecting multiple rows' info (/showthread.php?tid=336415)



[MySQL]Selecting multiple rows' info - [MG]Dimi - 22.04.2012

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?


Re: [MySQL]Selecting multiple rows' info - Hiddos - 22.04.2012

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


Re: [MySQL]Selecting multiple rows' info - [MG]Dimi - 22.04.2012

Nope, doesn't work.


Re: [MySQL]Selecting multiple rows' info - Richie© - 22.04.2012

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


Re: [MySQL]Selecting multiple rows' info - [MG]Dimi - 22.04.2012

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.


Re: [MySQL]Selecting multiple rows' info - Vince - 22.04.2012

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


Re: [MySQL]Selecting multiple rows' info - [MG]Dimi - 22.04.2012

Can you give me example then?


Re: [MySQL]Selecting multiple rows' info - Macluawn - 22.04.2012

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();



Re: [MySQL]Selecting multiple rows' info - [MG]Dimi - 22.04.2012

Ok. It works. Thanks Guys