[SOLVED] Count rows and produce an integer

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
ripcurlksm
Forum Commoner
Posts: 34
Joined: Sun Aug 08, 2004 9:17 pm

[SOLVED] Count rows and produce an integer

Post by ripcurlksm »

Hello all, Im new to the board....

I have a status table which can hold the values sold or selling, I want to do a count of how many items are currently selling and produce an integer as a result.

EX:

Items Selling: 3

Here is the start of my query:

Code: Select all

$result = mysql_query("SELECT bookmark, COUNT(*) as ??? FROM status WHERE status='selling' ");

echo "Items Selling: ???";
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

$query = mysql_query('SELECT COUNT(bookmark) FROM status WHERE status = ''selling''') or die(mysql_error());
list($count) = mysql_fetch_row($query);

echo 'Items Selling: ' . $count;
ripcurlksm
Forum Commoner
Posts: 34
Joined: Sun Aug 08, 2004 9:17 pm

Post by ripcurlksm »

Thanks!
Post Reply