This code will count the numbers of rows each name have and add up.
$pqfinal=0
$pq="select * from cmp where cid='$cid'";
$pqresult = mysql_query ($pq);
while($pqlist = mysql_fetch_array($pqresult)) {
$q="select * from cmp where pid='$pqlist[pmid]'";
$results = mysql_query ($q);
$pqcount = mysql_num_rows($results); //I have multiple rows from these results I want to add up
the rows from these results.
echo $pqlist['pmid']." = have ".$pqcount." rows<br>\n";
$pqfinal=$pqfinal+$pqcount;
}
echo "<br>total ".$pqfinal." rows";
My problem was, if the results have 2 same name how can I count as 1 results (mean only 7 rows instead of 14 rows based on the example).
name1 = have 7 rows
name1 = have 7 rows
name3 = have 6 rows
name4 = have 9 rows
Desire result will be
name1 = have 7 rows
name3 = have 6 rows
name4 = have 9 rows
$pqfinal=0
$pq="select * from cmp where cid='$cid'";
$pqresult = mysql_query ($pq);
while($pqlist = mysql_fetch_array($pqresult)) {
$q="select * from cmp where pid='$pqlist[pmid]'";
$results = mysql_query ($q);
$pqcount = mysql_num_rows($results); //I have multiple rows from these results I want to add up
the rows from these results.
echo $pqlist['pmid']." = have ".$pqcount." rows<br>\n";
$pqfinal=$pqfinal+$pqcount;
}
echo "<br>total ".$pqfinal." rows";
My problem was, if the results have 2 same name how can I count as 1 results (mean only 7 rows instead of 14 rows based on the example).
name1 = have 7 rows
name1 = have 7 rows
name3 = have 6 rows
name4 = have 9 rows
Desire result will be
name1 = have 7 rows
name3 = have 6 rows
name4 = have 9 rows