PHP functions for MySql : mysqli_fetch_assoc()

The mysqli_fetch_assoc() function fetches a result row as an associative array. The syntax is :
mysqli_fetch_assoc( result )
Where the $result is nothing but the returned object by mysqli_query() function.

Example :
<?php

  $server = "localhost";
  $username = "root";
  $password = "";
  $dbName = "mydb";

  $connection = mysqli_connect($server, $username, $password, $dbName);

  $sql = "SELECT * from employee";
  $result = mysqli_query($connection, $sql);

  $row = mysqli_fetch_assoc($result);

  echo $row["EmpId"] . " : " . $row["EmpName"] . "<br/>";

  mysqli_close($connection);

?>
Output :

101 : John

Next Topic :