[Question] MySQL Loading multi rows
#3

You see thats what I'm trying to do,

I have 5 sets of keys, 3 are for normal players and 2 more are for premium.
Now when a player logs in cID = vehicleid. It updates every time the server restarts.
so I need to put the vehicle id which is cID in the DB to load on player login in hte server,

This is what I made so far.
pawn Код:
new vString[900], vString2[900], idx = 0;
        format(vString, sizeof(vString), "SELECT * FROM `vehicles` WHERE cOwner='%s' ORDER BY cID ASC", EscapedName);
        mysql_query(vString2);
        mysql_store_result();
        new rows = mysql_num_rows();
        mysql_free_result();
       
        if(mysql_retrieve_row()) //data was retrieved
        {
            while (idx < rows)
            {
                if(idx == 0)
                {
                    mysql_get_field("cID", vString);
                    PlayerInfo[playerid][pPcarkey] = strval(vString);
                    idx++;
                }
                else if(idx == 1)
                {
                    mysql_get_field("cID", vString);
                    PlayerInfo[playerid][pPcarkey2] = strval(vString);
                    idx++;
                }
                else if(idx == 2)
                {
                    mysql_get_field("cID", vString);
                    PlayerInfo[playerid][pPcarkey3] = strval(vString);
                    idx++;
                }
                else if(idx == 3)
                {
                    mysql_get_field("cID", vString);
                    PlayerInfo[playerid][pPcarkey4] = strval(vString);
                    idx++;
                }
                else if(idx == 4)
                {
                    mysql_get_field("cID", vString);
                    PlayerInfo[playerid][pPcarkey5] = strval(vString);
                    idx++;
                }
           }
           mysql_free_result();
        }
But it only gives me the first vehicles id in the database on all my keys. Since I allready have 5 cars, but still I get the first cID on all keys, so it doesn't read the rest vehicles from the DB.

EDIT: Didn't get it to work, re-wrote the entire system and got the keys to load correctly.
Reply


Messages In This Thread
[Question] MySQL Loading multi rows - by tony_fitto - 23.11.2012, 22:02
Re: [Question] MySQL Loading multi rows - by ikey07 - 24.11.2012, 00:01
Re: [Question] MySQL Loading multi rows - by tony_fitto - 24.11.2012, 13:40

Forum Jump:


Users browsing this thread: 1 Guest(s)