Listing mySQL data
#1

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.
Reply
#2

SELECT * `banlist`
Reply
#3

That selects it - how do I display it..?
Reply
#4

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
Reply
#5

Can you give me an example without using sscanf?
Reply
#6

Can anyone give me an example without sscanf?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)