mysql problem
#2

pawn Код:
for(new i = 0;i<MAX_ORGS;i++)
Why? You're are retrieving the whole table MAX_ORGS times.

I'll rewrite the whole thing for you.
pawn Код:
CMD:orgs(playerid,params[])
{
    new orgsid, orgsname[50],lname[30], orgstr[150];
    format(query, sizeof(query), "SELECT * FROM orgs"); //This shouldn't be used too often
    mysql_query(query);
    mysql_store_result();
    if(mysql_num_rows() == 0)
    {
        mysql_free_result();
        return SendClientMessage(playerid, -1, "There are no organisations!");
    }
    SendClientMessage(playerid, -1, "Organizations:");
    while(mysql_retrieve_row())
    {
        //You can use fetch row and split it as well
        mysql_fetch_field_row(orgstr, "orgid"); orgsid = strval(orgstr);
        mysql_fetch_field_row(orgsname, "Name");
        mysql_fetch_field_row(lname, "Leader");
        format(orgstr, sizeof(orgstr), "Organization ID: %d || Organization Name: %s || Organization Leader: %s",orgsid,orgsname,lname);
        SendClientMessage(playerid,-1,str);
    }
    mysql_free_result();
    return 1;
}
Give that a go. If I have made an error, just correct it .
Reply


Messages In This Thread
mysql problem - by Tanush123 - 17.12.2011, 01:51
Re: mysql problem - by [HiC]TheKiller - 17.12.2011, 02:08
Re: mysql problem - by Tanush123 - 17.12.2011, 02:12

Forum Jump:


Users browsing this thread: 2 Guest(s)