SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I read 3 tutorials and coulnt find this anywhere

    How would I turn this SQL command into PHP?

    SELECT Author, COUNT(*) AS NumArticles FROM Count GROUP BY Author



    I think it is something like
    while (mysql_fetch_array(mysql_query("SELECT Author, COUNT(*) AS NumArticles FROM Count GROUP BY Author")))
    {
    $author=$row["Author"];
    $numarticles=$row["NumArticles"];
    echo ("$author - $numarticles");
    }

    But that doesnt work
    I want it to count all the articles posted by each author

    Thanks in advance
    Nate Gross
    DarkOps.com

  2. #2
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First do one query.

    Select DISTINCT Author
    blah blah

    Then while looping through the results of that query, do a series of queries that ask for your count where author = $author.

    Chris


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
  •