PHP loops and odd HTML output
===

When I create a loop to format some html like this:

	$pieces = Equipment::find_all();
	foreach($slots as $slot) { 
		echo "<h3>".ucfirst($slot)."</h3>";
		echo "<table class=\"eq_table\"><th><td>Name</td><td>P.AC</td><td>M.AC</td><td>Saves</td><td>Dex</td><td>Str</td><td>Int</td><td>Wis</td><td>Con</td><td>Hit</td><td>Dam</td><td>Hp</td><td>Mana</td></th>";
		foreach($pieces as $piece) {
			if($piece->slot == $slot) {
				echo "<tr><td>$piece->name</td><td>$piece->p_ac</td><td>$piece->m_ac</td><td>$piece->saves</td><td>$piece->dev</td><td>$piece->dex</td><td>$piece->str</td><td>$piece->intel</td><td>$piece->wis</td><td>$piece->con</td><td>$piece->hit</td><td>$piece->hit</td>$piece->dam</td><td>$piece->hp</td><td>$piece->mana</td></tr>";
			}
		}
	}

I get this obviously unwanted output:

![screenshot](http://db.tt/mtFD7Pec)

The bottom of the page has an extra table without a heading.  What is causing this behavior and how can I fix it?