AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Display multiline and multirow SQLQuery with show_modt (https://forums.alliedmods.net/showthread.php?t=54727)

the_mm 05-02-2007 11:27

Display multiline and multirow SQLQuery with show_modt
 
Hi comunity!
I have this Problem:
I have a SQL-DB which handles my top15-Players and I want fetch the top15-Data and display it whitch show_modt (like the statsx /top15)

Here is what I coded till now:

Code:

//Connect to the DB
 SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
  if(g_SqlTuple == Empty_Handle)
new Handle:Query = SQL_PrepareQuery(SqlConnection,"SELECT a.name, b.rank, c.kills, c.deaths, c.hits, c.shots, c.headshotkills, c.accuracy FROM ps_plr_ids a, ps_plr b, ps_c_plr_data c WHERE b.rank <=15 AND b.rank !=0 AND a.plrid=b.plrid AND b.plrid=c.plrid GROUP BY rank ORDER BY b.rank ASC;")
        run the query
    if(!SQL_Execute(Query))
    {
SQL_QueryError(Query,g_Error,511)
set_fail_state(g_Error)
}
 
    fputc(top15, '^n');
    fprintf(top15,"BLAAAA")
    new plnick[21]
    SQL_ReadResult(Query,0,plnick,20)
    new plrank = SQL_ReadResult(Query,1)
    new plkills = SQL_ReadResult(Query,2)
    new pldeaths = SQL_ReadResult(Query,3)
    new plhits = SQL_ReadResult(Query,4)
    new plshots = SQL_ReadResult(Query,5)
    new plheadshots = SQL_ReadResult(Query,6)
    new Float:placc
    SQL_ReadResult(Query,7,placc)
    new Float:pleff = (100 * float(plkills) / (float(plkills) + float(pldeaths)))
 %.2f",plrank, plnick, pldeaths, plhits, plshots, plheadshots, pleff, placc)


Zenith77 05-03-2007 15:26

Re: Display multiline and multirow SQLQuery with show_modt
 
Just put everything in a for loop.

Code:
static buffer[1024]; new len; buffer[0] = 0; len += format(buffer[len], 1023-len, "<html><h3>Top 15:</h3><br><br>"); new results = SQL_GetNumResults(query); for (new i = 0; i < results; i++) {      // Get data      len += format(buffer[len], 1023-len, "<li>Input all your data here...</li><br>");      SQL_NextRow(); } len += format(buffer[len], 1023-len, "</html>"); show_motd(id, buffer, "Top 15");

This hasn't been compiled or anything. Just a quick code snippet.


All times are GMT -4. The time now is 06:36.

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