Get thumbnails from specific posts

<ul >
<?php //The name of custom field you’d like to get, don’t forget to change it $custom_field_name = “featuredimg”; //Cool sql request $sql = “SELECT p.comment_count, p.ID, m.post_id, m.meta_key, m.meta_value FROM wp_posts p, wp_postmeta m WHERE p.ID = m.post_id LIMIT 0,10;”; $result = $wpdb->get_results($sql); foreach ($result as $topten) { $postid = $topten->ID; $title = $topten->post_title; $commentcount = $topten->comment_count; if ( $topten->meta_key == $custom_field_name) { $img = ‘meta_value.'” alt=””/>’; ?>
<li >< a href= “<?php echo get_permalink($postid); ?>”>
<?php echo $img; ?>
</li >
<?php } } ?> </ul >


thumbnails from specific post