SA-MP Forums Archive
MySQL listing all rows in a dialog - 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 listing all rows in a dialog (/showthread.php?tid=615877)



MySQL listing all rows in a dialog - Karan007 - 28.08.2016

Hey there,

i wanted to know how to list all rows in a table and show it into a dialog. Like showing all the clans in a dialog from a table. I just want a piece of code on how to do it.

- Thanks in advance!


Re: MySQL listing all rows in a dialog - Konstantinos - 28.08.2016

You did not mention what version of mysql you are using. This "piece of code" is for the latest versions:
PHP код:
// in a command to list all clans or whatever you want
mysql_tquery(handle_here"query_here""callback_here""i"playerid);
forward callback_here(playerid);
public 
callback_here(playerid)
{
    new 
rows cache_get_row_count();
    if (!
rows) return ... // error no clans
    
    
new info[256]; // change the size to hold the whole text
    
for (new i!= rowsi++)
    {
        
// retrieve the data.. use "i" as rowid
        
        
format(infosizeof info"%s format_here"info, ...);
    }
    
ShowPlayerDialog(...);
    return 
1;




Re: MySQL listing all rows in a dialog - Karan007 - 28.08.2016

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You did not mention what version of mysql you are using. This "piece of code" is for the latest versions:
PHP код:
// in a command to list all clans or whatever you want
mysql_tquery(handle_here"query_here""callback_here""i"playerid);
forward callback_here(playerid);
public 
callback_here(playerid)
{
    new 
rows cache_get_row_count();
    if (!
rows) return ... // error no clans
    
    
new info[256]; // change the size to hold the whole text
    
for (new i!= rowsi++)
    {
        
// retrieve the data.. use "i" as rowid
        
        
format(infosizeof info"%s format_here"info, ...);
    }
    
ShowPlayerDialog(...);
    return 
1;

Thank you, sir. By the way, i'm using the R39

EDIT: The code will list all clans and their names right?


Re: MySQL listing all rows in a dialog - Shinja - 28.08.2016

Yes as he said
PHP код:
// retrieve the data.. use "i" as rowid 
And you will get everything