Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2002
    Location
    Toronto, Canada
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Count(*) .... help please :)

    Am not sure what am doing wrong ... am trygin to count a number of rows in the db below is the statement;

    SELECT COUNT(*) FROM table_name;

    i mean this should work .. i think and i think in a way it does work, but the result i get is kind confusing ... it's not something i expected .. here it is below, ...


    Resource id #7

    thanx for all your help

    HormonX

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    need to see your code, assumin you are doing this (and assuming PHP)

    $yaks=mysql_query("SELECT COUNT(fieldname) FROM tablename");

    then if you echo $yaks (which is what I am assuming you are doing) you will get the result as per your post which is just a pointer to the actual result data and not the result itself... so you then have to...

    $row=mysql_result($yaks,0);//as we are only fetching 1 row mysql_result is ok - else do not use it !//
    echo $row;

    OR

    $row=mysql_fetch_row($yaks);
    echo $row[0];
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    New Coder
    Join Date
    Aug 2002
    Location
    Toronto, Canada
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you ...

    it works like magic ... i knew i was missing something

    thanx again


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •