NogDog Oh i'll try it too, right now I've changed my code a little to this
class IndexPage extends Database{
function drawIndex(){
$sql = "SELECT name, id, description, imagePath, imageName FROM restaurant";
$stmt = $this->connect()->query($sql);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
return $result;
}
}
useage
$test = new IndexPage();
$something = $test->drawIndex();
foreach($something as $row){
echo $row;
}
But that's not great and when I try
foreach($something as $row){
echo $row['name'];
}
I get
Warning: Illegal string offset 'name' in C:\Apache24\htdocs\rest\index.php on line 20
A
Notice: Trying to access array offset on value of type int in C:\Apache24\htdocs\rest\index.php on line 20
Warning: Illegal string offset 'name' in C:\Apache24\htdocs\rest\index.php on line 20
I
Warning: Illegal string offset 'name' in C:\Apache24\htdocs\rest\index.php on line 20
u
Warning: Illegal string offset 'name' in C:\Apache24\htdocs\rest\index.php on line 20
p