Why is my method only returning the first row of my table? I can't understand why and it's driving me nuts. I'm sure it's something very simple.
public function getTitlesForRegistrationForm() {
$result = $this->_db->query("SELECT UserTitleID, UserTitleName FROM UserTitles");
$i=0;
$array[0] = "No result";
foreach($result->fetch(PDO::FETCH_ASSOC) as $row){
$array[$i] = $row;
$i++;
}
return $array;
}
Thanks.
$result->fetch()returns a single row with each call. You are only calling it once …