The execute method will take an array and process it correctly. So
$sth->execute(@myarray) with an array of values should work just fine.
I have found that bad sql statments don't always throw errors the way we would expect. I had a similar issue with a silently failing sql statement. See the response at
node_id=231494.
I would also reccomend the excellent HTML:Template, or other templating module to take the HTML out of your code. It really is easier to use a templating module and keep HTML and code separate.
HTH,
digger