This is pretty easy. Just inline your php as needed into the html code to display on the page. For Example:
<?php
Inlcude your php and queries here in this block
?>
<!DOCTYPE html>
<html>
<head>
<title>Test Page</title>
<link rel="stylesheet" href="css/styles.css" />
</head>
<body>
<?php echo '<div class="elements">the rest of your php code goes here</div> '; ?>
</body>
</html>
This is just bare bones basic code to show you what I am talking about. So your custom css would live in the styles.css file. Once you echo out what it is you want in php, then it will inherit those styles. You can inline php as much as you want throughout the file. Just name it file.php or whatever you want.
This will allow you to do what it is you are asking. Of course you could reverse this and echo out the html from start to finish if you really wanted too, but it would be easier to just add the relevant connection info for php and query at the top of the page before any html and then echo out the specific information you wish inside the html below the main php code.
Also I noticed you have one too many closing div tags at the bottom of your echo statement. As others have already commented, you have some other errors as well.