fetch_array(MYSQLI_ASSOC) code example
Example 1: mysqli_fetch_assoc
<?php
$con = mysqli_query("hostname", "username", "pwd", "database");
$sql = "SELECT * FROM `TABLE`";
$result = mysqli_query($con, $sql);
$check = mysqli_num_rows($result);
if($check > 0){
while($data= mysqli_fetch_assoc($result)){
echo $data["ColName"];
}
}
?>
Example 2: mysqli load result into array
$resource = $db->query("SELECT * FROM users WHERE userid = '".$userid."'");
while($row = $resource->fetch_array()) { $the_rows[] = $row; }
/// later use like:
// foreach($the_rows as $row)
// {
// echo $row['product'];
// }