MySql While loop
#1

Hello,

I'm trying to get all the outside coords from my houses to place some icons on the map but the only thing i now get is 000000 000000 000000.

but there are 2 records into my db so i think my while loop is kinda wrong, can someone explain me how this while loop works on samp. I'm using the mysql R34.

Код:
forward loadHouses(playerid);
public loadHouses(playerid){
	SendClientMessage(playerid,YELLOW,"Loading houses...");
    new query[128],message[200],Float:Xc,Float:Yc,Float:Zc;
    mysql_format(mysql, query, sizeof(query),"SELECT `OX`, `OY`, `OZ` FROM `houses`");
    mysql_tquery(mysql, query, "", "");
    mysql_store_result();
    while(mysql_fetch_row(query))
	{
		new b[256];
		
		mysql_fetch_field_row(b,"OX");
		Xc = strval(b);
		
		mysql_fetch_field_row(b,"OY");
		Yc = strval(b);
		
		mysql_fetch_field_row(b,"OZ");
		Zc = strval(b);
		

		format(message, sizeof(message), "%f %f %f",Xc,Yc,Zc);
		SendClientMessage(playerid,YELLOW,message);
	}
	mysql_free_result();
}
Thnx,
Tom
Reply
#2

bumb
Reply
#3

Threaded queries (basically R7+) require a callback. Those parameters in mysql_tquery actually have a use. See the example on the wiki: https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_tquery
Reply
#4

can you just give me a example of a query with a while loop afther it to go trough all values ?

This is the query:
Код:
SELECT `OX`, `OY`, `OZ` FROM `houses`
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)