SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 26/02/2010, 12:48 PM   #1
actiwe
Big Clucker
 
Join Date: Jan 2010
Posts: 102
Reputation: 0
Default Counting with mysql queries

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 ?
actiwe is offline  
Old 26/02/2010, 01:10 PM   #2
WackoX
Guest
 
Posts: n/a
Default Re: Counting with mysql queries

totalhouses = mysql_num_rows();
 
Old 26/02/2010, 02:36 PM   #3
actiwe
Big Clucker
 
Join Date: Jan 2010
Posts: 102
Reputation: 0
Default Re: Counting with mysql queries

Yea, thanks WackoX . It helped me !
actiwe is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Little coding questions - For general minor queries 5 !damo!spiderman Scripting Help 4575 20/09/2018 09:51 AM
Counting gun amo? SMCentral Help Archive 4 28/01/2010 06:42 PM
SQL queries using GROUP BY Dabombber Help Archive 2 05/10/2009 07:47 PM
counting Sal_Kings Help Archive 2 12/05/2009 02:57 PM


All times are GMT. The time now is 01:40 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.