Counting total result and each result

Discussion in 'PHP' started by d1srupt3r, Jun 13, 2008.

  1. #1
    I have a problem, I can't make my script count each result but I can count the total result. The table I am using is "wn_synset" and the column is "ss_type" but it should be matched in the matched query in the column "word" which is also in the same table. My code for counting the total result is this:
    //Parts of Speech, contains in ss_type for echo
    $part_speech = array("n"=>"n.","v"=>"verb", "r"=>"adv./adj.", "a"=>"adj.", "s"=>"adj.");
    
    $counting = mysql_query('SELECT count(ss_type) FROM wn_synset WHERE word="'.str_replace(' ', '_', $word).'"');
    $total = mysql_fetch_array($counting);
    echo "Total: $total[0]";
    PHP:
    Now, how can I make it also count the result found if the word matched has "n", "v", "r"...? and not to echo the count that haven't matched in ss_type column? Sorry for the a lot of questions in PHP. :D
     
    d1srupt3r, Jun 13, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    sum? is the total of the values and not the total of the count.
     
    EricBruggema, Jun 13, 2008 IP
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    COUNT(*)
    SUM(FIELD_NAME)

    Peace,
     
    Barti1987, Jun 14, 2008 IP