php - Notice: Undefined offset: 1 in line 23 -


this question has answer here:

for school project needed change mysql database mongodb.

this old code working fine:

$movies = ''; $count = 0;  while($row_movie = mysqli_fetch_assoc($result)){ $count++;  $movies[$count] .= "{ value: '".$row_movie['naam']."', data:'".$row_movie['idproduct']."' }";  } 

now made foreach loop handle mongodb collection:

$collection = $colproduct; $products = $collection->find();  $result = $collection->find();  $movies = ''; $count = 0; foreach($result $row_movie){    $count++;    $movies[$count] .= $row_movie['naam'];    print_r($movies); } 

but 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 can me out! :)

method a: export mysql in csv format , use mongoimport tool. however, not work in terms of handling dates of binary data.

method b: script transfer in language of choice. write program reads mysql 1 element @ time , inserts mongodb.

method b better a, still not adequate.

$movies = array(); $count = 0;  while($row_movie = mysqli_fetch_assoc($result)){ $count++;  $movies[$count] .= "{ value: '".$row_movie['naam']."',  data:'".$row_movie['idproduct']."' }"; } 

the mongodb collection:

$collection = $colproduct; $products = $collection->find(); $result = $collection->find();  $movies = array(); $count = 0; foreach($result $row_movie){ $count++; $movies[$count] = $row_movie['naam']; print_r($movies); } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -