SA-MP Forums Archive
Counting with mysql queries - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Counting with mysql queries (/showthread.php?tid=130306)



Counting with mysql queries - actiwe - 26.02.2010

I made this to count how many houses i have, so i can make loop better.. First time the public works well, so it gives the right answer but if i run this public again it's answer is always zero..

Code:
public totalhouses()
{
	new query[64], Field[64];
	format(query, sizeof(query), "SELECT count(hsqlid) FROM `houses`");
	mysql_query(query);
	mysql_store_result();

	mysql_fetch_field_row(Field, "count(hsqlid)");
	totalhouses = strval(Field);

	mysql_free_result();
	format(query, sizeof(query), "Houses = %d",totalhouses);
	print(query);
	
 	return totalhouses;

}
Whats wrong here ?


Re: Counting with mysql queries - WackoX - 26.02.2010

totalhouses = mysql_num_rows();


Re: Counting with mysql queries - actiwe - 26.02.2010

Yea, thanks WackoX . It helped me !