LastLog CMD
#2

At first. The best idea is to store date in temporal types such as DATE, DATETIME, TIMESTAMP.
Secondly. Applying functions to table fields is undesirable in any DBMS.
And further. Avoid using mysql_query. Better use threaded mysql queries - mysql_tquery
The use of SQL functions on field can not be avoided here, so the working code should look like this:

PHP код:
CMD:lastlog(playerid)
{
    
mysql_tquery(
        
SQL,
        
"SELECT * FROM `users` WHERE str_to_date(`LastLog`, '%%d/%%m/%%Y') <= NOW() - INTERVAL 30 DAY ORDER BY `ID` DESC LIMIT 20",
        
"lastLogResponse", "d", playerid
    
);
    return 
1;
}
forward lastLogResponse(playerid);
public 
lastLogResponse(playerid)
{
    new 
szResult[32], szDialog[652] = "ID\tLastLog"; // IDK how long is data that u retrieve from database;
       
for (new i = 0, rowCount = cache_num_rows(); i < rowCount; i++)
    {
        
cache_get_field_content(i, "LastLog", szResult);
        
format(string, sizeof(string), "%s\n%d\t%s", i + 1, szDialog, szResult);
    }
    
ShowPlayerDialog(playerid, 123, DIALOG_STYLE_TABLIST_HEADERS, "LastLog", szDialog, "Select", "Close");
    return 
1;
} 
Reply


Messages In This Thread
LastLog CMD - by MarianImmortalGod - 20.11.2018, 15:49
Re: LastLog CMD - by =KempeR= - 20.11.2018, 19:59
Re: LastLog CMD - by MarianImmortalGod - 20.11.2018, 21:36
Re: LastLog CMD - by =KempeR= - 20.11.2018, 22:07
Re: LastLog CMD - by MarianImmortalGod - 22.11.2018, 11:49

Forum Jump:


Users browsing this thread: 1 Guest(s)