-1
請幫我,如何比較2名稱從不同的查詢? 我想比較subject1與subject2,如果它的相同單詞將打印'是'(如圖像)。
所以這是我的代碼,我的代碼剛剛讀取了subject1的最後一個查詢。 那麼如何比較來自subject1和所有subject2的所有查詢?
<table class="table table-bordered">
<tr>
<td class="table-bordered">No</td>
<td class="table-bordered">Date</td>
<td class="table-bordered">Subject Name</td>
<td class="table-bordered">Subject No</td>
<td class="table-bordered">Revision No</td>
<td class="table-bordered">Trainer</td>
<td class="table-bordered">Institution</td>
</tr>
<?php
$query = mysql_query("SELECT * FROM training_detail AS s JOIN materi AS t JOIN training_history AS u JOIN employee AS v WHERE v.employee_id = $id1 AND s.nik LIKE v.nik AND u.id_materi LIKE t.id_materi AND s.id_riwayat_training LIKE u.id_riwayat_training ");
$i=1;
while($row1 = mysql_fetch_array($query))
{
$date = $row1['date'];
$subject1 = $row1['subject_name'];
?>
<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['subject_no']; ?></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>
<?php
$i++;
}
?>
</table>
</br>
<table class="table table-bordered">
<tr>
Training yang belum diikuti
<td class="table-bordered">No</td>
<td class="table-bordered"></td>
<td class="table-bordered">subject id</td>
<td class="table-bordered">subject namei</td>
<td class="table-bordered">subject no</td>
</tr>
<?php
$query = mysql_query("SELECT * FROM job_name AS r JOIN subject AS q JOIN employee AS p WHERE q.subject_id LIKE r.header_id AND r.job_id LIKE p.id_jabatan AND p.id_karyawan = $id1 ORDER BY q.id_materi ASC ");
$i=1;
while($row2 = mysql_fetch_array($query))
{
$subject2 = $row2['subject_name'];
if (strcasecmp($subject1, $subject2) == 0)
{
?>
<tr>
<td class="table-bordered"><?php echo $i; ?></td>
<td class="table-bordered"><?php echo "YES" ?></td>
<td class="table-bordered"><?php echo $row2['subject_id'] ?></td>
<td class="table-bordered"><?php echo $subject2; ?></td>
<td class="table-bordered"><?php echo $row2['subject_no']; ?></td>
</tr>
<?php
}
else
{
?>
<tr>
<td class="table-bordered"><?php echo $i; ?></td>
<td class="table-bordered"><?php echo "NO" ?></td>
<td class="table-bordered"><?php echo $row2['subject_id'] ?></td>
<td class="table-bordered"><?php echo $subject2; ?></td>
<td class="table-bordered"><?php echo $row2['subject_no']; ?></td>
</tr>
<?php
}
$i++;
}
?>
</table>
如果要將query1的所有值與query2的所有值進行比較,則必須將第二個查詢放入第一個查詢中。 –
是的,我試過了,但結果只是爲我的主要清單。如何做出選擇? 我應該在哪裏放置代碼? 對不起我的可怕英語 –