Raised This Month: $ Target: $400
 0% 

Solved Broken table when supposed to work


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
GasmoN
Member
Join Date: Jul 2014
Old 09-29-2021 , 13:04   Re: Broken table when supposed to work
Reply With Quote #7

For some weird reason, width: 100% in .was the problem. When motd was printed it was printed without % (meaning, only width: 100 was printed) The solution to this is to add two percentage signs, like this: width 100%% and now it works like a charm. I also added missing </td> and </tr>'s

Full working code:
PHP Code:
public mysql_top15(FailStateHandle:QueryError[], ErrcodeData[], DataSize)
{
    if(
FailState)
    {
        
log_amx("SQL Error: %s (%d)"ErrorErrcode);
        return 
PLUGIN_HANDLED;
    }
    
    new 
gMotd[2048];

    if(
SQL_NumResults(Query) > 1)
    {
        new 
szName[33];
        new 
iName;
        new 
iKills;
        new 
iDeaths;
        new 
iHeadshots;

        new 
0;
        new 
len 0;

        
len += formatex(gMotd[len], charsmax(gMotd) - len"<!DOCTYPE html><html>");
        
len += formatex(gMotd[len], charsmax(gMotd) - len"<head><meta name='viewport' content='width=device-width, initial-scale=1'>")
        
len += formatex(gMotd[len], charsmax(gMotd) - len"<meta http-equiv='X-UA-Compatible' content='IE=edge' />")
        
len += formatex(gMotd[len], charsmax(gMotd) - len"<style>table { border-collapse: collapse; width: 100%%; border: 1px solid #ddd; } th, td { text-align: left; padding: 16px; }</style></head>");
        
len += formatex(gMotd[len], charsmax(gMotd) - len"<body><br><center><table><tr><th>Rank</th><th>Name</th><th>Kills</th><th>Deaths</th><th>Headshots</th></tr>");
        
        
iName SQL_FieldNameToNum(Query"name");
        
iKills SQL_FieldNameToNum(Query"kills");
        
iDeaths SQL_FieldNameToNum(Query"deaths");
        
iHeadshots SQL_FieldNameToNum(Query"headshots");
        
        
        while (
SQL_MoreResults(Query))
        {
            
len += formatex(gMotd[len], charsmax(gMotd) - len"<tr><td>%d</td>", ++k);
            
            
SQL_ReadResult(QueryiNameszNamecharsmax(szName));
            
            
len += formatex(gMotd[len], charsmax(gMotd) - len"<td>%-22.22s</td>"szName);
            
len += formatex(gMotd[len], charsmax(gMotd) - len"<td>%d</td>"SQL_ReadResult(QueryiKills));
            
len += formatex(gMotd[len], charsmax(gMotd) - len"<td>%d</td>"SQL_ReadResult(QueryiDeaths));
            
len += formatex(gMotd[len], charsmax(gMotd) - len"<td>%d</td></tr>"SQL_ReadResult(QueryiHeadshots));
    
            
SQL_NextRow(Query);
        }
    
        
len += formatex(gMotd[len], charsmax(gMotd) - len"</table></center></body></html>");
        
    }

    
show_motd(Data[0], gMotd"Top 15 Players");
    
    return 
PLUGIN_HANDLED;
    

Thank you guys for your replies.

Last edited by GasmoN; 09-29-2021 at 13:05. Reason: [code] changed to [php]
GasmoN is offline
 


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 20:26.


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