Getting a List from a MySQL table - 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: Getting a List from a MySQL table (
/showthread.php?tid=415867)
Getting a List from a MySQL table -
Neil. - 15.02.2013
pawn Код:
CMD:companies(playerid, params[])
{
new CompanyQuery[128],Companyname[150];
format(CompanyQuery,sizeof(CompanyQuery), "SELECT name FROM companies ORDER BY clanname DESC LIMIT 0,10");
mysql_query(CompanyQuery);
mysql_store_result();
new diag[128];
format(diag, sizeof(diag), "%s\n", CompanyQuery); //I'm not sure about this
mysql_free_result();
ShowPlayerDialog(playerid, 1990, DIALOG_STYLE_LIST, "Companies", diag, "Select", "Close");
return 1;
}
Well, i'm stuck. Tried a couple of ways before but the result was just ONE company showing up in the dialog. If I have 10 companies. I want to display 10 of them. But I don't know how
Re: Getting a List from a MySQL table -
Vince - 15.02.2013
pawn Код:
new
result[24], // or whatever the max length of the name of a company is
output[240];
while(mysql_fetch_row(result))
{
strcat(output, result);
strcat(output, "\n");
}