Count array created by msql selection

Novax

New Member
I need to select some images inside a table by its ID (duplicate entrys allowed).My maincode:\[code\]...$selectedImages = $this->selectImages($selectedNews['ID'][$i]);//Check valuesecho 'Count of Array: '.sizeof($selectedImages)."\n";if (sizeof($selectedImages) == 0) { $this->html[] = '-';} else { for ($j = 0; $j < sizeof($selectedImages); $j++) { $this->html[] = '<a class="fancybox single_image" href="http://stackoverflow.com/'.$selectedImages['Path'][$j].$selectedImages['Name'][$j].'"><img src="http://stackoverflow.com/questions/15915238/thumbnail/thumb.php?src=../../'.$selectedImages['Path'][$j].$selectedImages['Name'][$j].'&h=50&w=50" alt="'.$selectedImages['Name'][$j].'" /></a>'; }}...\[/code\]and this is my Method:\[code\]private function selectImages($id) { $selectedImages = array(); $sql = "SELECT Name, Path FROM News_images WHERE Pos = '".mysqli_real_escape_string($this->db, $id)."' "; $stmt = $this->db->prepare($sql); if (!$result = $this->db->query($sql)) { echo 'Datenbankfehler\n'; echo $this->db->error; } $i = 0; while ($row = $result->fetch_assoc()) { $selectedImages['Path'][$i] = $row['Path']; $selectedImages['Name'][$i] = $row['Name']; $i++; } echo 'Selected: '.$i.' images ,'; return $selectedImages;}\[/code\]I get following output:Selected 1 images, Count of Array: 2Selected 0 images, Count of Array: 0Selected 4 images, Count of Array: 2The actual amount of selected images is the correct one. But the count of the Array does not match the count of the actual selection.Whats the problem here?
 
Top