So I have this code that shows top15 players on the server, and while it works like a charm, I have issue with the HTML part of the code. Table's width is not 100%, and I have tried like 100 times to fix that and it simply won't work. Does anyone at least know what the issue here is and what should I try to do next?
PHP Code:
public mysql_top15(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
if(FailState)
{
log_amx("SQL Error: %s (%d)", Error, Errcode);
return PLUGIN_HANDLED;
}
new gMotd[2048];
if(SQL_NumResults(Query) > 1)
{
new szName[33];
new iName;
new iKills;
new iDeaths;
new iHeadshots;
new k = 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", ++k);
SQL_ReadResult(Query, iName, szName, charsmax(szName));
len += formatex(gMotd[len], charsmax(gMotd) - len, "<td>%-22.22s", szName);
len += formatex(gMotd[len], charsmax(gMotd) - len, "<td>%d", SQL_ReadResult(Query, iKills));
len += formatex(gMotd[len], charsmax(gMotd) - len, "<td>%d", SQL_ReadResult(Query, iDeaths));
len += formatex(gMotd[len], charsmax(gMotd) - len, "<td>%d", SQL_ReadResult(Query, iHeadshots));
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;
}