For a school project I needed to change my MySQL database to a MongoDB.
This is my old code that is working fine:
$movies = '';
$count = 0;
while($row_movie = mysqli_fetch_assoc($result)){
$count++;
$movies[$count] .= "{ value: '".$row_movie['naam']."', data:'".$row_movie['idProduct']."' }";
}
Now I made a foreach loop to handle the MongoDB collection:
$collection = $colProduct;
$products = $collection->find();
$result = $collection->find();
$movies = '';
$count = 0;
foreach($result as $row_movie){
$count++;
$movies[$count] .= $row_movie['naam'];
print_r($movies);
}
But now I get the error: Notice: Undefined offset: 1 in D:\wamp64\www\examen.yvde.nl\currency-autocomplete.php on line 23
(this line: $movies[$count] .= $row_movie['naam'];)
I hope anyone can help me out! Thanks :)