私は次のようなウェブサイト構造を持っています
<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 } ?>
$title
whileループステートメントの上にあるhtml要素の変数を引き続き使用または呼び出す方法はありますか?
whileループの上で呼び出すたびに、次のようなエラーが発生しますUndefined variable: id..
編集: 代わりに id を 'title' に変更