如何在数据库中获取数据的结果中使用for循环的值来进行编号?
$ count = 2
然后我希望PRocess Step有一个编号
处理步骤1
流程第2步
for($i=1;$i<=$count;$i++){
echo $i;
echo "<br>";
}
while($proc = $process->fetch()){?>
<div class="processLeft form">
<label>
Process Step <?php echo $i?>:
<input type="text" id="aline" value="<?php echo $proc['process_step']; ?>">
</label>
</div>
<div class="processRight form">
<label>
Temperature(°C):
<input type="text" id="aline" value="<?php echo $proc['temp'] . " " . "Degrees"; ?>">
</label>
</div>
<br>
<?php }
?>
答案 0 :(得分:0)
在while
循环中增加变量。
$i = 1;
while($proc = $process->fetch()){?>
<div class="processLeft form">
<label>
Process Step <?php echo $i?>:
<input type="text" id="aline" value="<?php echo $proc['process_step']; ?>">
</label>
</div>
<div class="processRight form">
<label>
Temperature(°C):
<input type="text" id="aline" value="<?php echo $proc['temp'] . " " . "Degrees"; ?>">
</label>
</div>
<br>
<?php $i++;
}
答案 1 :(得分:0)
我不确定你想做什么...... 如果我猜对了,就像这样
<?php
$i=1;
while($proc = $process->fetch()) : ?>
<div class="processLeft form">
<label>
Process Step <?php echo $i?>:
<input type="text" id="aline" value="<?php echo $proc['process_step']; ?>">
</label>
</div>
<div class="processRight form">
<label>
Temperature(°C):
<input type="text" id="aline" value="<?php echo $proc['temp'] . " " . "Degrees"; ?>">
</label>
</div>
<br/>
<?php $i++; endwhile; ?>