Upvote:1
Madrid is in Spain, in the Schengen zone of the European Union. A visa is not required for Philippine citizens if you have an immediate connecting flight leaving Schengen from the same airport.
However, Miami is in the United States and a visa is required for Philippine citizens. Unlike most of the world, the US does not recognize the concept of sterile transit, meaning everybody has to pass through Immigration.