how to compare 2 values from 2 table?
i have using 2 while (nested while) but the table check one by one and the result in second table is from each row in first table. how to make the result printed once?
i want the result like this result's image
and here is my currently code
<?php
$query1 = mysql_query("SELECT * FROM riwayat_training_detail AS s JOIN materi AS t JOIN riwayat_training AS u JOIN karyawn AS v WHERE v.id_karyawan = $id1 AND s.nik LIKE v.nik AND u.subject no LIKE t.subject no AND s.id_riwayat_training LIKE u.id_riwayat_training ");
$i=1;
while($row1 = mysql_fetch_array($query1))
{
$date = $row1['date'];
$subject1 = $row1['subject name'];
?>
<table class="table table-bordered">
<tr>
Training yang diikuti
<td class="table-bordered">No</td>
<td class="table-bordered">date</td>
<td class="table-bordered">subject date</td>
<td class="table-bordered">No SOP</td>
<td class="table-bordered">revision no</td>
<td class="table-bordered">Trainer</td>
<td class="table-bordered">institution</td>
</tr>
<tr>
<td class="table-bordered"><?php echo $i; ?></td>
<td class="table-bordered"><?php echo date("j/F/Y", strtotime($date)); ?></td>
<td class="table-bordered"><?php echo $subject1; ?></td>
<td class="table-bordered"><?php echo $row1['no_sop']; ?></td>
<td class="table-bordered"><?php echo $row1['revision_no']; ?></td>
<td class="table-bordered"><?php echo $row1['trainer']; ?></td>
<td class="table-bordered"><?php echo $row1['institution']; ?></td>
</tr>
</br>
<table class="table table-bordered">
<tr>
Training yang belum diikuti
<td class="table-bordered">No</td>
<td class="table-bordered">subject no</td>
<td class="table-bordered">subject date</td>
<td class="table-bordered">No SOP</td>
</tr>
<?php
$query2 = mysql_query("SELECT * FROM header_jabatan AS r JOIN materi AS q JOIN karyawn AS p WHERE q.subject no LIKE r.id_header AND r.id_jabatan LIKE p.id_jabatan AND p.id_karyawan = $id1 ORDER BY q.subject no ASC");
$x=1;
while($row2 = mysql_fetch_array($query2))
{
$subject2 = $row2['subject name'];
if (strcasecmp($materi1, $materi2) != 0)
{
?>
<tr>
<td class="table-bordered"><?php echo $i; ?></td>
<td class="table-bordered"><?php echo $row2['subject no'] ?></td>
<td class="table-bordered"><?php echo $subject22; ?></td>
<td class="table-bordered"><?php echo $row2['no_sop']; ?></td>
</tr>
<?php
}
$x++;
}
$i++;
}
?>
</table>
</table>
please help me what should i do?
it's my second question with same topic, i really need help im stuck with this..