SA-MP Forums Archive
Listing mySQL data - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Listing mySQL data (/showthread.php?tid=244617)



Listing mySQL data - MP2 - 27.03.2011

My server stores bans in a mySQL table. I want to make a command for admins - /banlist. It should list all the bans in the table. How would I go about doing that?

I have very little experience in mySQL, but hopefully some of you may know how and be able to help me.


Re: Listing mySQL data - mprofitt - 27.03.2011

SELECT * `banlist`


Re: Listing mySQL data - MP2 - 28.03.2011

That selects it - how do I display it..?


Re: Listing mySQL data - [L3th4l] - 28.03.2011

pawn Код:
new
    BannedName[MAX_PLAYER_NAME],
    BannedBy[MAX_PLAYER_NAME],
    BannedReason[50],
    iStr[50];

mysql_query("SELECT * FROM `baninfo`");
mysql_store_result();

if(mysql_num_rows() > 0)
{
    while(mysql_fetch_row(iStr))
    {
        sscanf(iStr, "p<|>s[24]s[25]s[50]", BannedName, BannedBy, BannedReason);
 
        // Display it using dialogs or something using the above variables ^
    }
}
mysql_free_result();
If using something like that, your sql dump should look like:

Table: baninfo
Columns: BannedName, BannedBy, BannedReason <- Edit to fit your system


Re: Listing mySQL data - MP2 - 29.03.2011

Can you give me an example without using sscanf?


Re: Listing mySQL data - MP2 - 03.04.2011

Can anyone give me an example without sscanf?