php mysql query to db displays only resource id 228?

I have a query:
'SELECT `project`, COUNT(*) FROM `table-name` GROUP BY `project`

the only thing it returns is "Resource id #228"

I have no idea what this means or why the query returns this message, any help would be appreciated.
LVL 1
digitalkandyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
$res = mysql_query("SELECT `project`, COUNT(*) as ct FROM `table-name` GROUP BY `project`") or die( mysql_error() );
while( $row = mysql_fetch_assoc($res) )
{
 echo $row['project'] . " " . $row['ct'];
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
digitalkandyAuthor Commented:
you are a rock star!

just curious as to what the "Resource id' means, if you care to explain I would appreciate it, if not I understand.

Thanks for taking the time.
0
hieloCommented:
when you execute this:
$res = mysql_query(...);

$res does NOT contain the result of the query. It contains "something" that "points to/holds"  the real data. That "something" is referred to as "resource" in php. So if you do:
echo $res;

you are NOT getting the real data. You are getting the resource that points to the place where your real data is stored. Instead you need to "extract" the data from the resource. That's what this does:
$row = mysql_fetch_assoc($res )

it "extracts" the data from the resource and puts in in $row. So $row contains the actual data.
0
digitalkandyAuthor Commented:
nice, thank you for the explanation, it always helps to know the why and not just the how.
0
hieloCommented:
>>it always helps to know the why and not just the how
agree.

Glad to help. Take care.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.