Raised This Month: $ Target: $400
 0% 

Display multiline and multirow SQLQuery with show_modt


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
the_mm
New Member
Join Date: May 2007
Old 05-02-2007 , 11:27   Display multiline and multirow SQLQuery with show_modt
Reply With Quote #1

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)
the_mm is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 05-03-2007 , 15:26   Re: Display multiline and multirow SQLQuery with show_modt
Reply With Quote #2

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.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred

Last edited by Zenith77; 05-03-2007 at 15:29.
Zenith77 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 06:36.


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