This is a VERY helpfull topic.
I want to do the same thing but instead of just the latest attachment, i want to pull ALL attachments for a post.
How do i turn this query into something that generates an array of all the files.
$attachment_id = $wpdb->get_var(“SELECT ID FROM $wpdb->posts WHERE post_parent = ‘$post->ID’ AND post_status = ‘inherit’ AND post_type=’attachment’ ORDER BY post_date DESC LIMIT 1”);