While there's a next row (in MySQL R33)
#1

fixed.
Reply
#2

double post. sorry
Reply
#3

No, you need to use a loop as there is no function to go to the next row. A while loop works pretty well for this. Try something like this:

pawn Код:
public OnHouseLoad()
{
    new rows, fields, idx;
    cache_get_data(rows, fields, mysql);
   
    if(rows)
    {
        while(idx < rows)
        {
            HouseCount++;
            houseInfo[HouseCount][slots] = cache_get_field_content_int(idx, "slots");
            houseInfo[HouseCount][ownerid] = cache_get_field_content_int(idx, "ownerid");
            houseInfo[HouseCount][price] = cache_get_field_content_int(idx, "price");
           
            houseInfo[HouseCount][house_x] = cache_get_field_content_float(idx, "house_x");
            houseInfo[HouseCount][house_y] = cache_get_field_content_float(idx, "house_y");
            houseInfo[HouseCount][house_z] = cache_get_field_content_float(idx, "house_z");
           
            if(ownerid != -1)
            {
                mysql_format(mysql, query, sizeof(query), "SELECT username FROM accounts WHERE id = %d", ownerid);
                mysql_tquery(mysql, query, "GetNameFromID", "i", ownerid);
            }
            else
            {
                houseInfo[HouseCount][ownername] = GetNameFromID(
            }
            idx++;
        }
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by Chenko
Посмотреть сообщение
No, you need to use a loop as there is no function to go to the next row. A while loop works pretty well for this. Try something like this:

pawn Код:
public OnHouseLoad()
{
    new rows, fields, idx;
    cache_get_data(rows, fields, mysql);
   
    if(rows)
    {
        while(idx < rows)
        {
            HouseCount++;
            houseInfo[HouseCount][slots] = cache_get_field_content_int(idx, "slots");
            houseInfo[HouseCount][ownerid] = cache_get_field_content_int(idx, "ownerid");
            houseInfo[HouseCount][price] = cache_get_field_content_int(idx, "price");
           
            houseInfo[HouseCount][house_x] = cache_get_field_content_float(idx, "house_x");
            houseInfo[HouseCount][house_y] = cache_get_field_content_float(idx, "house_y");
            houseInfo[HouseCount][house_z] = cache_get_field_content_float(idx, "house_z");
           
            if(ownerid != -1)
            {
                mysql_format(mysql, query, sizeof(query), "SELECT username FROM accounts WHERE id = %d", ownerid);
                mysql_tquery(mysql, query, "GetNameFromID", "i", ownerid);
            }
            else
            {
                houseInfo[HouseCount][ownername] = GetNameFromID(
            }
            idx++;
        }
    }
    return 1;
}
Cheers!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)