How are you doing the replacement? My guess is that it's matching everything from the first % in the first template slot to the last % in the last template slot. That's based on one interpretation of your question. Another, based on a different interpretation, is that the same value is being substituted for each of the template slots, so that the same value is used over and over again. This suggests a problem with your loop and/or extraction of data from the database.
I'd use preg_replace() - faster, more powerful, and you're soaking in it.
preg_replace('/%entry(\d+)%/e',"\$entry[\\1]", $html);
Assuming the entries are in an array named $entry[], numbered the same way as in the template.
Gee, you could do that with several arrays at once:
preg_replace('/%([A-Za-z_]+)(\d+)%/e', "\$\\1[\\2]", $html);
I'm gonna have to remember that.