Postingan lainnya
stop looping while
pagi semuanya, saya bikin looping while pake fetch array di php, gimana cara stop while kalau data sudah ter-fetch semua ?
<form method="POST" action="storedata_g6b.php">
<table class="table">
<thead class="thead-dark">
<tr>
<th class="col-3">id</th>
<th class="col-7">nama</th>
<th class="col-3">rank</th>
</tr>
</thead>
<tbody>
<?php
$rank_b = 'B';
$sql = "select t_empeval.id, t_empeval.nama from t_empeval Where t_empeval.grade='$c' and sect=CONCAT('$a','$b') order by t_empeval.v1 desc limit ".$var1.",".$var2."";
$query = mysqli_query($koneksi, $sql);
if(!$query)
{
die('SQL Error' . mysqli_error($koneksi));
}
$i=0;
while ($array_b = mysqli_fetch_assoc($query))
{
if(mysqli_num_rows($query) > 0)
{
?>
<tr>
<td><input type="text" name="id_b[<?php echo $b; ?>]" value="<?php echo $array_b['id']; ?>"></td>
<td><input type="text" name="nama_b[<?php echo $b; ?>]" value="<?php echo $array_b['nama']; ?>"></td>
<td><input type="text" name="rank_b[<?php echo $b; ?>]" value="<?php echo $rank_b; ?>"></td>
</tr>
$i++;
}
}
<input type="hidden" name="cotton_b" value="<?php echo $b; ?>" />
</tbody>
</table>
<input type="submit" id="submit" name="submit"/>
</form>
mohon bantuannya untuk yang lebih paham. Terimakasih banyak
0
1 Jawaban:
<div>Coba pake "break;"<br><br>Source: https://www.php.net/manual/en/control-structures.break.php</div>
0