绑定变量获取的例子
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
//绑定变量获取的例子//输出变量的过程如下:// 01) 预备(解析)语句 02) 执行预备语句 03) 绑定输出变量 04) 把数据提取到输出变量中$conn = mysqli_connect('127.0.0.1', 'afei2', '123456', 'test');$conn->query("set names utf8mb4");$stmt = $conn->prepare("SELECT id,name,kecheng,score FROM student_01");$stmt->bind_result($id, $name,$kecheng,$score);//这里定义的变量$stmt->execute();print "<table border='1' >" . PHP_EOL;print "<tr><th>ID</th><th>姓名</th><th>课程</th><th>分数</th></tr>" . PHP_EOL;while ($stmt->fetch()) { print "<tr><td>$id</td><td>$name</td><td>$kecheng</td><td>$score</td></tr>" . PHP_EOL;}print "</table>" . PHP_EOL;$stmt->close(); |










