I have a loop that never ends and its only pulling one record from the database.
I have a class that returns a list then I call that class function on a website where the while loop never stops echoing the data.
class exampleclass
{
public function get_list()
{
$query = $dbh->prepare("SELECT .. blah);
$query->bindParam("blah");
$query->execute();
return $query->fetch(PDO::FetchObj);
}
on the web page i have:
<?php
testobj = new exampleclass();
while ($obj = $testobj->get_list())
{
echo $obj->db_field;
}
?>
It pulls the one record from the database but it doesn't stop looping, it should just loop once.