i have a website structure as follow
<div id="title">
<h1> //call $title here after executing loop </h1>
</div>
<?php
...
while ($row = $result->fetch_assoc()) { $title = $row['title']; ?>
<h2> this is the <?php echo $title;?> </h2>
<?php } ?>
is there a way i could still use or call the $title
variable on an html element on top of the while loop statement?
whenever i call it above the while loop i get errors like Undefined variable: id..
edit: change id into 'title' instead