Mysql Issue
#1

Some reason this is only loads the top record could anyone please help me out?

Код:
forward LoadMyReports(playerid);
public LoadMyReports(playerid)
{
    if(!cache_num_rows()) return SendClientMessage(playerid, COLOR_GRAY, "{1E90FF}(Server):{dadada} You don't have any open reports!");
     
    new str[3200], showReason[200], stats[100];

    format(str, sizeof(str), "ID\tVictim\tReason\tStatus\n");
	for(new i = 0, x = cache_get_row_count(SQL_CONNECTION); i < x; i++)
	{
		
		new showSQLID = cache_get_field_content_int(i, "SQLID");
		new showVictim =cache_get_field_content_int(i, "vID");
		cache_get_field_content(i, "Reason", showReason);
		new showStatus = cache_get_field_content_int(i, "Status");

		switch(showStatus)
		{
			case 0: stats = "{00FF00}Open";
			case 1: stats = "{DE4816}Being Handled";
		}
		
		format(str, sizeof(str), "%s%d\t%s\t%s\t%s\n", str, showSQLID, GetNameFromDB(showVictim), showReason, stats);
	}
	
	ShowPlayerDialog(playerid, DIALOG_MYREPORTS, DIALOG_STYLE_TABLIST_HEADERS, "Your Reports", str, "Close","Close");
	return true;
}
Reply
#2

cache_get_row_count(&destination); returns the row count in the destination parameter. The return value is either 1 on success or 0 on failure. Meaning your code will indeed only show the first result only.

https://sampwiki.blast.hk/wiki/MySQL/R40..._get_row_count
Reply
#3

so what way would i fix this?
Reply
#4

Generally I just fetch the count without checking the result of the function.

Код:
...
new count; cache_get_row_count(count);

for(new i = 0; i < count; i++)
{
   ...
Reply
#5

Now it shows nothing
Reply
#6

Ah sorry, it appears you are on another mysql version as I though. Your original implementation seems correct.

https://sampwiki.blast.hk/wiki/MySQL/R33..._get_row_count

Without more information I have no idea why there is only one result.
Reply
#7

Which my SQL version are you using?
Reply
#8

Check your code, you are getting data only from the first row
Pass to the next row inside the loop
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)