Getting a List from a MySQL table
#1

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
Reply
#2

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");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)