我写了这段代码,我想用css来设置它。我添加了样式但是同样的结果出现可以让任何身体帮助。
<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>
答案 0 :(得分:0)
<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>";
}