Can be done in a number of ways. This snip counts the number of occurences line-by-line.
$count = 0;
$fd = fopen("yourfile.html", "r");
while(!feof($fd)) {
$s = fgets($fd, 4096);
$count += substr_count($s, "<td id=");
}
fclose ($fd);
print $count;
Can be done simpler if there never is more than one occurence of "id" per line, but this way you get a correct count if there are serveral. However, if the "message" contains the text substr_count searches for, the count will be wrong...