I have a programming code problem, I need help to solve the problem.
How to explode data array using MYSQL and using NOT IN.
The program code is below
<form style="overflow: hidden;" method="post">
<div class="table-responsive">
<?php
$sql = "SELECT * FROM kursus WHERE KodKursus NOT IN
(SELECT kursusList FROM pensyarahkursus WHERE IDUser= '$value');";
$stmt = $db->query($sql);
$i = 1;
if ($stmt->rowCount() > 0) { ?>
<table class="table table-hover table-bordered table-striped" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<td style="width: 10px;"></td>
<th style="width: 20px;">#</th>
<td>Semester</td>
<td>Kod Kursus</td>
<td>Nama Kursus</td>
</tr>
</thead>
<tbody>
<?php
while ($row = $stmt->fetch()) {
echo "<tr>"; ?>
<td>
<input type="checkbox" aria-label="Checkbox for following text input" name="kursus[]" value="<?php echo $row['IDKursus']; ?>">
</td>
<th><?php echo $i ?></th>
<td><?php echo $row['Semester']; ?></td>
<td><?php echo $row['KodKursus']; ?></td>
<td><?php echo $row['NamaKursus']; ?></td>
<?php
echo "</tr>";
$i++; } ?>
</tbody>
</table>
<?php
} else {
echo "<br>";
echo "<center><h4> Tiada Rekod</h4></center>";
} ?>
</div>
<div class="d-flex justify-content-between mt-3">
<button type="submit" class="btn btn-success" name="daftar_kursus">Daftar Kursus</button>
<button type="reset" class="btn btn-primary">Reset</button>
</div>
</div>
</form>
Picture below sample data pensyarahKursus
Picture bewlow sample data from kursus