DefineItFast
06-15-2008, 05:11 PM
I have a code that needs to count for the total value and each value that has matched in the column. Please the code:
//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).'"');
$countnoun = mysql_query('SELECT count(WHERE ss_type="n") FROM wn_synset WHERE word="'.str_replace(' ', '_', $word).'"');
$total = mysql_fetch_array($counting);
$totalnoun = mysql_fetch_array($countnoun);
$count = 0;
$countnoun = 0;
//this is in a loop
$count = $count + 1;
$countnoun = $countnoun + 1;
echo "Total: $total[0]<br />";
if ($totalnoun[0] > 0) {
echo "-$totalnoun[0] nouns</h2>";
}
I thought my code was correct now but I had this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
The line with error is this line:
$totalnoun = mysql_fetch_array($countnoun);
What's wrong with code? The echo for the total cound value works but the count for the nound doesn't.:confused: Thank you in advance for trying to help me. :)
PS
By the way, I am new here. Glad to be here.:thumbsup:
//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).'"');
$countnoun = mysql_query('SELECT count(WHERE ss_type="n") FROM wn_synset WHERE word="'.str_replace(' ', '_', $word).'"');
$total = mysql_fetch_array($counting);
$totalnoun = mysql_fetch_array($countnoun);
$count = 0;
$countnoun = 0;
//this is in a loop
$count = $count + 1;
$countnoun = $countnoun + 1;
echo "Total: $total[0]<br />";
if ($totalnoun[0] > 0) {
echo "-$totalnoun[0] nouns</h2>";
}
I thought my code was correct now but I had this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
The line with error is this line:
$totalnoun = mysql_fetch_array($countnoun);
What's wrong with code? The echo for the total cound value works but the count for the nound doesn't.:confused: Thank you in advance for trying to help me. :)
PS
By the way, I am new here. Glad to be here.:thumbsup: