SA-MP Forums Archive
MySql While loop - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySql While loop (/showthread.php?tid=531665)



MySql While loop - Tommboow - 13.08.2014

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


Re: MySql While loop - Tommboow - 15.08.2014

bumb


Re: MySql While loop - Vince - 15.08.2014

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


Re: MySql While loop - Tommboow - 15.08.2014

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`