querying HTML and PHP for a page
<!doctype html>
<meta charset= "UTF-8" >
<meta name= "Viewport"
Content= "Width=device-width, User-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" >
<meta http-equiv= "x-ua-compatible" content= "Ie=edge" >
<title>Document</title>
<style type= "Text/css" >
table.imagetable {
Font-family:verdana,arial,sans-serif;
font-size:11px;
Color: #333333;
border-width:1px;
Border-color: #999999;
Border-collapse:collapse;
}
table.imagetable th {
Background: #b5cfd2 url (' cell-blue.jpg ');
border-width:1px;
padding:8px;
Border-style:solid;
Border-color: #999999;
}
Table.imagetable TD {
Background: #dcddc0 url (' cell-grey.jpg ');
border-width:1px;
padding:8px;
Border-style:solid;
Border-color: #999999;
}
</style>
<body>
<table class= "ImageTable" >
<tr>
<th>id</th>
<th> name </th>
<th> Password </th>
<th> Sex </th>
<th> Department </th>
<th> class </th>
<th> Telephone </th>
</tr>
<?php
Header (' Content-type:text/html;charset=utf-8 ');
Include_once ("conn/conn.php"); Import Database Control page introduced
$sql = "Select*from user"; Querying the user in the database;
$r =mysqli_query ($link, $sql);
$row =mysqli_fetch_array ($R); Types of arrays queried
while ($row =mysqli_fetch_array ($r)) {
/*print_r ($row);
echo "<br>"; * *
/* echo $row ["name"]. " = ". $row [" Mima "]; Query names and passwords can also be queried by keys
echo "<br>"; * *
?>
<tr>
<td><?php echo $row ["id"]?></td>
<td><?php echo $row ["Name"]?></td>
<td><?php echo $row ["Mima"]?></td>
<td><?php echo $row ["Xingbie"]?></td> <!--data from a database loaded with tables--
<td><?php echo $row ["Xibu"]?></td>
<td><?php echo $row ["Banji"]?></td>
<td><?php echo $row ["Tex"]?></td>
</tr>
<?php
}
?>
</table>
</body>
PHP code in the database
<?php
$host = "localhost";//Specify Host name and IP address
$db _user= "root"; Database user
$db _pass= ""; Database Password
$db _name= "Sqlclass1"; Database Database to use
$timezone = "Asia/shanghai";//Shanghai time
$link =mysqli_connect ($host, $db _user, $db _pass, $db _name);//mysqli_connect open a new connection to the MySQL server
Mysqli_query ($link, "Set names UTF8"),//link is the specified MySQL connection to be used after the encoding format is set
Header ("content-type:text/html; Charset=utf-8 ");
Date_default_timezone_set ($timezone); GMT
?>
Database query data into a table