Loading reports from database
#1

hey there i saved every report on database MySql but when i load it it seems like wont work and it shows only 1 line not all

heres code where i load em


Код:
function:ReportList(playerid)
{
	new rows, fields;
	cache_get_data(rows, fields, MySQLPipeline);
	if(rows)
	{
		for(new row = 0; row < rows; row++)
		{
			new iMessage[128],Repotredby[128],ReporedTime[128],Reason[128], pName[MAX_PLAYER_NAME];
			cache_get_field_content(row, "ReportedBy", pName, MySQLPipeline);
			cache_get_field_content(row, "Reported", Repotredby, MySQLPipeline);
			cache_get_field_content(row, "TimeDate", ReporedTime, MySQLPipeline);
			cache_get_field_content(row, "Reason", Reason, MySQLPipeline);
			format(iMessage,sizeof(iMessage),"%s - %s - %s -%s",pName,Repotredby,ReporedTime,Reason);
			SendClientMessage(playerid, COLOR_GREY, iMessage);
	    return 1;
		}
	}
	return 1;
}
Command

Код:
COMMAND:reports(playerid, params[])
{
 
	new iQuery[300];
	mysql_format(MySQLPipeline, iQuery, sizeof(iQuery), "SELECT `Reported`, `ReportedBy`, `TimeDate`, `Reason` FROM `Reports`");
	mysql_tquery(MySQLPipeline, iQuery, "ReportList", "d", playerid);
	return 1;
}
Reply
#2

Quote:

format(iMessage,sizeof(iMessage),"%s - %s - %s -%s",pName,Repotredby,ReporedTime,Reason);
SendClientMessage(playerid, COLOR_GREY, iMessage);

Well the above code outputs a one liner. What do you expect then?
Reply
#3

Because you're using return 1; under the loop and you're resetting the row count to 0! I also changed the function to show a dialog instead of sending messages in the chat.

Correct code:
PHP код:
function:ReportList(playerid)
{
    new 
rowsfields;
    
cache_get_data(rowsfieldsMySQLPipeline);
    if(
rows)
    {
        new 
str[128 rows], iMessage[128], Repotredby[128], ReporedTime[128], Reason[128], pName[MAX_PLAYER_NAME];
        for(new 
irowsi++)
        {
            
cache_get_field_content(row"ReportedBy"pNameMySQLPipeline);
            
cache_get_field_content(row"Reported"RepotredbyMySQLPipeline);
            
cache_get_field_content(row"TimeDate"ReporedTimeMySQLPipeline);
            
cache_get_field_content(row"Reason"ReasonMySQLPipeline);
            
format(iMessagesizeof iMessage,"%d) %s - %s - %s - %s",1pNameRepotredbyReporedTimeReason);
            
strcat(striMessage);
        }
        
ShowPlayerDialog(playerid0DIALOG_STYLE_MSGBOX"Reports list"str"Okay""");
    }
    return 
1;

Reply
#4

It doesnt really work , it shows only 1 line and all shows only "Null"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)