Mysql Issue - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql Issue (
/showthread.php?tid=647413)
Mysql Issue -
JessThompson - 04.01.2018
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;
}
Re: Mysql Issue -
Mikro - 04.01.2018
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
Re: Mysql Issue -
JessThompson - 04.01.2018
so what way would i fix this?
Re: Mysql Issue -
Mikro - 04.01.2018
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++)
{
...
Re: Mysql Issue -
JessThompson - 04.01.2018
Now it shows nothing
Re: Mysql Issue -
Mikro - 04.01.2018
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.
Re: Mysql Issue -
iLearner - 05.01.2018
Which my SQL version are you using?
Re: Mysql Issue -
Lucases - 05.01.2018
Check your code, you are getting data only from the first row
Pass to the next row inside the loop