// header("Content-type: text/html; charset=utf-8");
// function vertifyUser($usern, $passw){
$serverN = "localhost";
$serverUN = "root";
$serverPS = "root";
$serverDB = "myDB";
$conn = new mysqli($serverN, $serverUN, $serverPS,$serverDB);
if($conn->connect_error){
die("连接失败". $conn->connect_error);
}
// $sql = "create table Students ("
// . "id int(6) unsigned auto_increment primary key,"
// . "firstname varchar(30) not null,"
// . "lastname varchar(30) not null,"
// . "phone int(11))";
// $sql = "insert into Students (firstname, lastname, phone) values"
// . "('姓', '名', '1352566363')";
// if($conn->query($sql) === TRUE){
// echo "创建成功";
// } else {
// echo "创建失败". $conn->error;
// }
// $stmt = $conn->prepare("insert into Students (firstname, lastname, phone) values (?, ?, ?)");
// $stmt->bind_param("ssi", $first, $last, $pho);
// $first = "ce";
// $last = "shi";
// $pho = 999999;
// $stmt->execute();
// $first = "ce1";
// $last = "shi1";
// $pho = 8888;
// $stmt->execute();
// $stmt->close();
// $sql = "select id, firstname, lastname, phone from Students";
// $result = $conn->query($sql);
// if ($result->num_rows > 0) {
// while ($row = $result->fetch_assoc()) {
// echo $row["id"]. "--". $row["firstname"]. "--". $row["lastname"]. "--". $row["phone"]. "
";
// }
// }else{
// echo "失败";
// var_dump($result);
// }
// $sql = "select * from Students order by firstname asc";
// $result = $conn->query($sql);
// // echo $result->num_rows;
// if ($result->num_rows > 0) {
// while ($row = $result->fetch_assoc()) {
// echo $row["id"]. "--". $row["firstname"]. "--". $row["lastname"]. "--". $row["phone"]. "
";
// }
// }
$sql = "select * from Students where firstname regexp '[学]'";
$result = $conn->query($sql);
// echo $result->num_rows;
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo $row["id"]. "--". $row["firstname"]. "--". $row["lastname"]. "--". $row["phone"]. "
";
}
}
$conn->close();
?>