mysqli fetch assoc - 语法
mysqli_fetch_assoc(result);
它用于获取作为关联数组的输出行。
Sr.No | 参数 & Description |
---|---|
1 |
result 它指定mysqli_query()、mysqli_store_result()或mysqli_use_result()返回的输出集标识符 |
mysqli fetch assoc - 返回值
它返回表示提取行的字符串的关联数组。
mysqli fetch assoc - 示例
<?php $connection_mysql=mysqli_connect("localhost","user","password","db"); if (mysqli_connect_errno($connection_mysql)){ echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="SELECT name,salary FROM emp"; $result=mysqli_query($connection_mysql,$sql); $row=mysqli_fetch_assoc($result); print $row["name"]; print "\n"; print $row["salary"]; mysqli_free_result($result); mysqli_close($connection_mysql); ?>