A: $data['id']
B: $data['name']
C: $data[0]
D: $data[1]
举一反三
- 有以下程序代码,其中能输出name的是( )$conn = mysqli_connect('localhost','root','root','test');$result = mysqli_query($conn,'select id,name,sex from user where id=1');$data = mysqli_fetch_row($result); A: $data[1] B: $data[0] C: $data->name D: $data['name']
- 以下程序代码的输出结果为( )$conn = mysqli_connect('localhost','root','root','test');$result = mysqli_query($conn,'select id,name,sex from user where id=1');$data = mysqli_fetch_array($result);echo $data[0]; A: 1 B: 2 C: 0 D: 空值
- 以下程序代码实现的功能是( )$conn = mysqli_connect('localhost','root','root','test');$result = mysqli_query($conn,'select id,name from user');$data = mysqli_fetch_all($result,MYSQLI_ASSOC);foreach ($data as $v){ if($v['id'] == 5){ echo $v['name']; }} A: 输出所用用户的name B: 输出第一位用户的name C: 输出id=5的用户的name D: 输出id不为5的用户的name
- 以下程序代码实现的功能是( )$conn = mysqli_connect('localhost','root','root','test');$result = mysqli_query($conn,'select * from user');while ($data=mysqli_fetch_array($result)){ echo $data['id'].$data['name'].'<br/>';} A: 输出user表所有用户id和name B: 输出user表第一位用户id和name C: 输出user表最后一位用户id和name D: 输出报错
- 以下代码运行结果为( )$conn = mysqli_connect('localhost','root','root','test');$result = mysqli_query($conn,'select * from user');$data = mysqli_fetch_array($result); A: 变量data保存了user表所有数据 B: 变量data保存了user表1条数据 C: 变量data保存了user表的2条数据 D: 变量data保存了user表的3条数据
内容
- 0
以下程序输出结果为( )$conn = mysqli_connect('localhost','root','root','test');$result = mysqli_query($conn,'select * from user');$data = mysqli_num_rows($result);echo $data A: 输出user表所有记录 B: 输出user表记录总数 C: 输出user表第一条数据 D: 输出user表最后一条数据
- 1
假设有一个数据库db_shop中有一个表tb_shop,表中有5个字段,主键为id,有20条记录,id从0到19,以下代码输出结果是( )。$conn = mysqli_connect("localhost", "root", "111", "db_shop");mysqli_query($conn,"set names utf8");$result=mysqli_query($conn,"select * from tb_shop where id<;6");$nums=mysqli_num_rows($result);echo $nums; A: 0 B: 4 C: 5 D: 6
- 2
对下列程序代码理解正确的是 [?php$conn = Mysqli_connect(“localhost”,”root”,”123456”,”test”) or die(“数据库连接失败!”);$sql = “select id,name,age,sex,phone,email from user where age]20 and sex=’男’”;$result = mysqli_query($conn,$sql);while($row = mysqli_fetch_assoc($result)){echo $row[‘id’].’[br][/br]’;}Mysqli_close($conn);?> A: 数据库连接失败时,将显示“数据库连接失败”并退出程序。 B: 可以获得user表中所有年龄超过20的男生信息。 C: 在浏览器中输出年龄超过20的男生id。 D: 改代码最后没有释放资源。
- 3
下面( )函数从结果集中取得一行记录,返回的只是数字索引数组。 A: mysqli_query B: mysqli_fetch_array C: mysqli fetch row D: mysqli fetch assoc
- 4
假设已经通过MySQLi扩展建立与数了据库的连接,连接对象是$mysqli。现在请写出代码:执行查询语句"SELECT * FROM student",然后输出查询结果的行数。 A: $result = $mysqli->query("SELECT * FROM student"); echo $mysqli->num_rows; B: $result = $mysqli->query("SELECT * FROM student"); echo $mysqli->$num_rows; C: $result = $mysqli->query("SELECT * FROM student"); echo $result->num_rows; D: $result = $mysqli->query("SELECT * FROM student"); echo $result->$num_rows;