[英]How can I use the number of rows in no. the fetch data?
How can I use the value of for loop to use at numbering in the result of fetch data from database? 如何从数据库中获取数据的结果中使用for循环的值进行编号?
$count = 2
$ count = 2
then I want the PRocess Step to have a numbering 然后我要在“处理步骤”中进行编号
Process Step 1
处理步骤1
Process Step 2
处理步骤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 }
?>
Increment the variable in your while
loop. 在您的
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++;
}
i'm not sure about what you want to do ... If i'm guessing right it's just something like this 我不确定您要做什么...如果我猜对了,就是这样
<?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; ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.