如何设置我的PHP代码结果?

I wrote this code and I want to style it with css. I added style to it but same result appears can any body help please .

<p>
<phpcode> 
<?php           
$term = mysql_real_escape_string($_REQUEST['term']);
$servername = "localhost";
$username = "***********";
$password = "***********";
$dbname = "*************";
$conn = new mysqli($servername, $username, $password, $dbname); 
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}   

$sql = "SELECT Install ,  power , RPM FROM SN WHERE serial = '$term'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {

    while($row = $result->fetch_assoc()) {
        echo "serial number: " . $term.'<br>';
        echo "installation: " . $row["Install"].'<br>';
        echo "power: " . $row["power"].'<br>';
        echo "RPM: " . $row["RPM"].'<br>';

    }
} else {
    echo "no result";
}
$conn->close();         
?> 
</phpcode>
</p>
<style>
    .results div:nth-of-type(1){
        color:red;
        background:blue;
        font-size:3rem;
    }
    .results div:nth-of-type(2){
        color:blue; 
        background:yellow;
        font-size:2rem;
    }
    .results div:nth-of-type(3){
        color:green;
        background:orange;
        font-size:1rem;
    }
    .results div:nth-of-type(4){
        color:orange;
        background:black;
        font-size:0.5rem;   
    }
</style>




    while( $row = $result->fetch_assoc() ) {
        echo "
        <div class='results'>
            <div>serial number:{$term}</div>
            <div>installation:{$row['install']}</div>
            <div>power:{$row['power']}</div>
            <div>rpm:{$row['rpm']}</div>
        </div>";
    }