MySQL always selecting 1st row
#1

At first, I want to point out that I am still learning MySQL, and my problem is, it's always selecting first row from my database. I debugged my code with item_uid and objectid.

I can easly pick up first object but I cannot do it to the second one, debug says it's trying to pick up UID: 1 of objectid: -1.

But it should be UID: 2 of objectid: 2.

Code:
pawn Код:
new data[40], Float:X, Float:Y, Float:Z, item_uid, objectid;
GetPlayerPos(playerid, X, Y, Z);

new query[140 + 40];
format(query, sizeof(query), "SELECT `UID`, `objectid` FROM `items` WHERE (`x` - %f < 1.5) AND (`x` - %f > -1.5) AND (`y` - %f < 1.5) AND (`y` - %f > -1.5) LIMIT %d, %d", X, X, Y, Y, listitem, listitem + 1);
mysql_query(query);

mysql_store_result();
mysql_fetch_row(data);
sscanf(data, "p<|>dd", item_uid, objectid);

format(query, sizeof(query), "UID: %d | ObjectID: %d", item_uid, objectid);
SCM(playerid, -1, query);

DestroyObject(objectid);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 0, 1, 1, 0, 0, 1);

format(query, sizeof(query), "UPDATE `items` SET `objectid` = -1, `owner_uid` = %d WHERE `UID` = %d", PlayerData[playerid][E_PLAYER_UID], item_uid);
mysql_query(query);

mysql_free_result();
Creating object is fine, UID and objectid inserted into database is fine, just here, it loads wrong.
Reply
#2

You have to loop every row
Reply
#3

edit:\\
Nevermind, my fault now. Thanks, I forgot about the loop.

edit2:\\
That wasn't loop fault. I didn't need it )
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)