Retrieving the COUNT...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Sinnix
Forum Commoner
Posts: 43
Joined: Mon Apr 28, 2003 11:01 am
Location: Ottawa, ON Canada
Contact:

Retrieving the COUNT...

Post by Sinnix »

I've got this MS SQL query

Code: Select all

$ms_result = (mssql_query("SELECT count(cellname) FROM cell_table WHERE ((state=27)OR((state=28)AND(pstate_id=0))) AND (current_operator='$uname')"));
... and this code...

Code: Select all

$cell_edit = (mssql_fetch_row($ms_result));
... and a return of "array". I normally understand how to retieve information from a mssql query... but this is a little different because I'm doing a COUNT. Any suggestions??
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

you're going to want to use whats called an alias in your mysql query so count(field) will be count(field) as newname

what that does is say take the value of counting that field and make it a new variable called newname

now when you pull it out of the array the name will be "newname" just like any other variable. Hope that helps
Sinnix
Forum Commoner
Posts: 43
Joined: Mon Apr 28, 2003 11:01 am
Location: Ottawa, ON Canada
Contact:

Post by Sinnix »

Helps?? Are you kidding! ;) You just solved my problem! You freakin' rule. Thanks doOd. :D 8)
Post Reply