画像をforで表示[php]

<?php
if(get_post_meta($post->ID,img1,TRUE)||get_post_meta($post->ID,img1,TRUE)||get_post_meta($post->ID,img1,TRUE)){
 echo "<table id='thum_img'><tr>";
for ($i = 1; $i <= 3; $i++) {
$img = 'img'.$i;
$title = 'title'.$i;
$img_thm = wp_get_attachment_image(post_custom($img),'thumbnail');
if(get_post_meta($post->ID,$img,TRUE)){
echo "<td class='".$img."'>";
echo $img_thm;
echo '<p>'.get_post_meta($post->ID,$title,TRUE).'</p>';
echo "</td>";
}
}
echo "</tr></table>";
}//fast if end
?>