I want to separate the values that come out of the DB by a comma. I can't find an SQL way to do it, and if I try to do it in the while loop it puts a comma on the end of the string, which I do not want.
private function retrieve_subjects(){
$dbh = $this->connect();
$stmt = $dbh->prepare("SELECT name FROM subject");
$stmt->execute();
$stmt->bindColumn('name', $name);
while($stmt->fetch(PDO::FETCH_BOUND)){
$sub .= $name;
}
return $sub;
}