PHP コードの後に HTML の下半分が表示されないページがあります。表示させる唯一の方法は、 WHILEループの最後にRETURNを配置することでした。これにより、ループも終了しました。おそらく単純なものであり、それが何であるかを知る必要があることはわかっています。よろしくお願いします。
HTML:
<table border='0'>
<thead>
<tr>
<th scope="cols">Select</th>
<th scope="cols">Name</th>
<th scope="cols">Units</th>
<th scope="cols">Amounts</th>
<th scope="cols">Calories</th>
<th scope="cols">Sugars</th>
</tr>
</thead>
<tbody>
<?php
//Establishs the DB connection
$sql = new Mysql();
//Queries the Foods
$sql->food();
?> <!--NOTHING SHOWS FROM HERE DOWN-->
</tbody>
</table>
<h2>Training Plan</h2>
<table id="dairy">
<thead>
<tr>
<th scope="cols">Select</th>
<th scope="cols">Name</th>
<th scope="cols">Units</th>
<th scope="cols">Amounts</th>
<th scope="cols">Calories</th>
<th scope="cols">Sugars</th>
</tr>
...more HTML....
PHP 関数:
function food() {
//Query's the DB
$result = $this->conn->query("SELECT * FROM ingredient") or die(mysql_error());
//Display's all of the Contents in the DB
while ($row = $result->fetch_assoc() or die(mysql_error()))
{
echo'<tr class="normal" id="row'.$row['id'].'" onclick="onRow(this.id);">'."\n\t\t\t\t\t\t\t".'<td><input type="checkbox" value="'.$row['id'].'" id="checkbox" /></td>'."\n\t\t\t\t\t\t\t";
echo'<td>'.$row['Name'].'</td>'."\n\t\t\t\t\t\t\t";
echo'<td>'.$row['Units'].'</td>'."\n\t\t\t\t\t\t\t";
echo'<td>'.$row['Amount'].'</td>'."\n\t\t\t\t\t\t\t";
echo'<td>'.$row['Calories'].'</td>'."\n\t\t\t\t\t\t\t";
echo'<td>'.$row['Sugar'].'</td>'."\n\t\t\t\t\t\t";
echo'</tr>'."\n\t\t\t\t\t\t";
}
}