I have the following query
$sql = "SELECT nomInteretUser from userInteret where idUser='$id_user' ";
$result = $conn->query(sprintf($sql));
I want to produce an array with following structure: array ('User1','User2')
I have tried this :
if ($result->num_rows != 0) {
$rows=array();
while($r=mysqli_fetch_assoc($result))
{
$rows[]=$r;
}
}
But it gives following result:
{
array(1) {
["nomInteretUser"]=> "foot"
}
array(1) {
["nomInteretUser"]=> "cyclisme"
}
}
$rows[]=$r["nomInteretUser"]?