SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    398
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how could i go about doing this

    i think the best way to explain what im trying to do is through an example. so, here goes. say i have a mysql table structured like this


    id -- size -- sex
    1 -- medium -- men
    2 -- large -- men
    3 -- large -- women
    4 -- medium -- men
    5 -- small -- women
    6 -- large -- women
    7 -- medium -- men
    8 -- small -- men
    9 -- large -- men

    and id like to have my information displayed like this

    mens

    small - 1
    medium - 3
    large - 2

    how would it do that?

    thanks

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    5 Thread(s)
    SELECT COUNT(t.`size`) AS mens,t.`size` AS size FROM `table` AS t WHERE t.`sex` = 'men' GROUP BY t.`size`;

    Does that workout for you?

  3. #3
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    398
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that would be the sql right? what would the php look like? the whole mysql_fetch_array() part....

    thanks oddz

  4. #4
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    while($row = mysq_fetch_array($result, MYSQL_NUM))
    {
    printf("&#37;s - %s<br />", $row[0], $row[1]);
    }

  5. #5
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    398
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks


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
  •