SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: mysql count

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql count

    Can someone tell me why this doesn't produce a count in PHP. It does from mysql.

    $mtg_num = @mysql_query("SELECT COUNT(*)from meetings");
    echo $mtg_num ;

    what I get is resource id 4


    what I want is to be able to produce the number of meetings in Toledo (or something)

    From mysql I can type:

    SELECT COUNT(*) FROM MEETINGS where city = 'Toledo';

    and get the right answer.

  2. #2
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need something like this

    PHP Code:
    $mtg_num = @mysql_query("SELECT COUNT(*) as count FROM meetings");
    $d mysql_fetch_array($mtg_num);
    echo(
    $d['count']); 
    Hope that helps
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us


Bookmarks

Posting Permissions

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