如何比較2表中的2個值?如何比較2個表中每行的2個值?
我已經使用2 while(nested while),但表中檢查一個一個,第二個表中的結果是從第一個表中的每一行。 如何使結果打印一次?
我想這樣 result's image
,這裏的結果是我目前的代碼
<?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>
請幫我我應該怎麼辦?
這是我用同一主題的第二個問題,我真的需要幫助,即時通訊堅持這個..
請不要使用mysql_ *函數的http:/ /stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php – n00bstacker
您的查詢如何運行...?語法完全破碎... – Siyual