- Edited
Doing something like this is mostly a style choice?
<?php
class IndexPage{
function drawIndex(){
try{
$db = new Database();
$sql = $db->prepare('SELECT name AS restaurant, id, description, imagePath FROM restaurant');
$sql->execute();
echo "<div class='flex-grid'>";
echo "<div class='header'>
<section>
<h1>Eating out in Kirkcaldy</h1>
<span class='para'><p>Explore Kirkcaldy's local restaurants find deals on your favourite international cuisine</p></span>
</section>
</div>";
echo "<div class='restaurants'>
<section class='kirkcaldy'>
<h1>Eating out in Kirkcaldy</h1>
<p>
Explore restaurants in Kirkcaldy boasts a verity international cuisine from around the world and local traditional meals,
from traditional fish & chips, Indian, Nepalese,
Turkish and Japanese street food Kirkcaldy has it all.
</p>
</section>
</div>";
echo "<div class='restaurant-heading'><h1>Restaurants</h1></div>";
echo "<div class='flex-grid-shops'>";
foreach($sql as $rows){
echo "<div class='rows'>";
echo "<div class='shop-img'>";
echo "<a href='restaurant.php?id={$rows['id']}'><img src='{$rows['imagePath']}'></a>";
echo '</div>';
echo "<section class='description'>";
echo "<a href='restaurant.php?id={$rows['id']}'>";
echo "<h1>". $rows['restaurant']."</h1>";
echo "<p>". $rows['description']."</p>";
echo "</a>";
echo '</section>';
echo '</div>';
}
echo "</div>";
echo "</div>";
}
catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
}
}