我正在尝试使用 mysql 在循环中执行一些循环,但似乎没有解释
它只返回第一个结果,即使我的数据库中有很多记录,它也应该返回所有内容
下面是我显示结果的代码
while ($cr = mysql_fetch_assoc($result)):
$i = 0;
++$i;
?>
<div style="width:200px" class="fif"><table style="width:100%">
<tr class="fbgreybox">
<td colspan="3" style="text-align: center;font-weight: bold">
<img src="images/calendar_2.png"> Séance du : <?php echo date('d-m-Y', strtotime($cr['record'])); ?>
</td>
</tr>
<?php
$sql = "SELECT `exercise` FROM `workouts` WHERE `record` = '{$cr['record']}' AND `user`= {$_SESSION['userid']} GROUP BY `exercise`";
$result = mysql_query($sql);
while ($exo = mysql_fetch_assoc($result)) :
?>
<tr class="fbinfobox">
<td colspan="3" style="text-align: left">
<img src="images/Sport-dumbbell.png"> ////<?php echo exerciseName($exo['exercise']); ?>
</td>
</tr>
<tr>
<td style="text-align: center;font-weight: bold">Séries</td>
<td style="text-align: center;font-weight: bold">Reps</td>
<td style="text-align: center;font-weight: bold">Poids</td>
</tr>
<?php
$rqt = "SELECT `set_number`, `reps`, `weight` FROM `workouts` WHERE `exercise` = {$exo['exercise']} AND `record` = '{$cr['record']}' AND `user` = {$_SESSION['userid']} ORDER BY `set_number`";
$result2 = mysql_query($rqt);
while ($detail = mysql_fetch_assoc($result2)):
?>
<tr>
<td>
Série ////<?php echo $detail['set_number']; ?>
</td>
<td>
<?php echo $detail['reps']; ?>
</td>
<td>
<?php echo $detail['weight']; ?>
</td>
</tr>
<?php
endwhile;
endwhile;
?>
</table>
</div>
<?php
endwhile;
代码中没有错误,所以我真的不明白为什么它没有被解释。
任何帮助将不胜感激。