-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path7-selectdata.php
More file actions
33 lines (30 loc) · 1021 Bytes
/
7-selectdata.php
File metadata and controls
33 lines (30 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
</head>
<body>
<?php
//链接数据库,php 和 MySQL 是兄弟。只需要一个命令就可以链接了
//数据库用户名是root 密码 root 本地localhost
//$con 就是一个变量,表示一次连接
$con = mysql_connect("localhost","root","root");
//选择连接哪个库
mysql_select_db("mydb",$con);
//执行mysql语句 ,吧检索结果放到$result 变量中
$result = mysql_query("SELECT * FROM tongxue");
//循环读取
while($row = mysql_fetch_array($result)){
echo "姓名是:" . $row['xingming'];
echo "<br/>";
echo "qq号是:" . $row['qqhao'];
echo "<br/>";
echo "手机号是:" . $row['shoujihao'];
echo "<br/>";
}
?>
</body>
</html>