Raised This Month: $ Target: $400
 0% 

PHP / SQL list table


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 09-24-2011 , 17:53   PHP / SQL list table
Reply With Quote #1

Hey, could someone share a code of a table with list from SQL.

Like I've table player rankings in my SQL and I want to show them as top 30 descending by skill.
reinert is offline
modernwarfare
Senior Member
Join Date: Aug 2011
Location: sweden
Old 09-24-2011 , 20:08   Re: PHP / SQL list table
Reply With Quote #2

Quote:
Originally Posted by reinert View Post
Hey, could someone share a code of a table with list from SQL.

Like I've table player rankings in my SQL and I want to show them as top 30 descending by skill.

Code:
public Show_Rank(id)
{
    for(new i; i < g_iMaxPlayers; i++)
    {
        if(is_user_connected(i) && get_cvar_num("SaveXP") == 1  && !is_user_bot(id)) {
           SaveData(i)
        }
    }
        
    new Data[1]
    Data[0] = id
    
    new szTemp[512]
    format(szTemp,charsmax(szTemp),"SELECT COUNT(*) FROM `xpmod` WHERE `xp` >= %d", PlayerXP[id])
    SQL_ThreadQuery(g_SqlTuple,"Sql_Rank",szTemp,Data,1)
        
    return PLUGIN_CONTINUE
}
public Sql_Rank(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(FailState == TQUERY_CONNECT_FAILED)
            log_amx("Load - Could not connect to SQL database.  [%d] %s", Errcode, Error)
    else if(FailState == TQUERY_QUERY_FAILED)
            log_amx("Load Query failed. [%d] %s", Errcode, Error)
  
    new count = 0
    count = SQL_ReadResult(Query,0)
    if(count == 0)
    count = 1
    
    new id
    id = Data[0]

    client_print(id, print_chat, "[XP Mod] %L", id, "RANK", count, PlayerLevel[id] , PlayerXP[id])
    
    return PLUGIN_HANDLED
}
public ShowTop15(id)
{
    //i must save stat for will haven't error into top15.
    //
    new Data[1]
    Data[0] = id
    
    // no need for a variable since it's not being formatted
    /*new Temp[512]
    format(Temp,charsmax(Temp),"SELECT steamid, xp FROM xpmod ORDER BY xp DESC LIMIT 15;")
    SQL_ThreadQuery(g_SqlTuple,"Sql_Top15",Temp,Data,1)*/
    SQL_ThreadQuery(g_SqlTuple,"Sql_Top15","SELECT steamid, xp FROM xpmod ORDER BY xp DESC LIMIT 15;",Data,1)
    return PLUGIN_CONTINUE;
}
public Sql_Top15(FailState,Handle:hQuery,Error[],Errcode,Data[],DataSize) 
{
    // get player who is looking at top
    new id = Data[ 0 ];
    
    // check for errors
    if( FailState == TQUERY_CONNECT_FAILED
    ||  FailState == TQUERY_QUERY_FAILED )
    {
        log_amx( "Error on top15 query (%i): %s", Errcode, Error );
        console_print( id, "Error on top15 query (%i): %s", Errcode, Error );
        return;
    }
    
    new szSteamID[ 35 ], PlayerXP;
    new iPos = 1;
    
    while( SQL_MoreResults( hQuery ) )
    {
        SQL_ReadResult( hQuery, 0, szSteamID, charsmax( szSteamID ) );
        PlayerXP = SQL_ReadResult( hQuery, 1 );

        client_print(id,print_chat, "[XP Mod] %L", id, "RANK2", iPos, szSteamID, PlayerXP);
        
        iPos++;
        SQL_NextRow( hQuery );
    }
}
this is what i use for my ranking system
__________________
Im supporting/coding XP Mod Plugin
Free Palestine
R.I.P. The 2967 American people that lost their lives 9/11 and R.I.P.
The 48,644 Afghan and 1,690,903 Iraqi people that paid the ultimate price for a crime they did not commit.



modernwarfare is offline
Send a message via MSN to modernwarfare Send a message via Skype™ to modernwarfare
reinert
Veteran Member
Join Date: Feb 2007
Old 09-25-2011 , 02:50   Re: PHP / SQL list table
Reply With Quote #3

I need PHP not AMXX
reinert is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-25-2011 , 16:04   Re: PHP / SQL list table
Reply With Quote #4

this is amxx scripting help section...
jimaway is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 09-25-2011 , 16:42   Re: PHP / SQL list table
Reply With Quote #5

Someone moved my thread >.< anyways delete thread, already made list
reinert is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode