Dynamic text based on title on every wordpress post. (With example)

They have: 5 posts

Joined: Aug 2007

Hi, the sample PHP code is

<?php $page_name = "run-scanner";
                                   
$page_content = $wpdb->get_results('SELECT `post_content` FROM `wp_posts` WHERE `post_name` = "'.$page_name.'"' );
                                    echo
$page_content[0]->post_content;
                               
?>

Where I believe it pulls the name of the scanner and inserts it in a div that wraps it all up.

Can you do this within a Wordpress Post? I have trouble getting it to work, I don't think I can execute PHP within the wordpress post... any ideas?