これは私のコードです。私はデータベーステーブルのitemIDに基づいて出力を印刷したいと思います。配列とループを使って各itemIDの出力をそれぞれどのように出力するのですか?これを行う最善の方法は何ですか?今のPHPでselect文を使用して配列をループする方法
<?php $result=mysql_query("select * from item where itemID='2'")or die (mysql_error());
$get_row=mysql_fetch_array($result);
?>
<?php echo $get_row['No']; ?>.<?php echo $get_row['Item']; ?> :<?php echo $get_row['Unit']; ?> unit
<br>
</br>
<center>
<table border="1" width="1000" height="80">
<thead>
<tr>
<th>Nama</th>
<th>Jenama</th>
<th>Model</th>
<th>No_Siri</th>
<th>Tagging</th>
<th>Tarikh_Diterima</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<?php $emp_query=mysql_query("select * from service_record where itemID='2' order by Nama");
while($row=mysql_fetch_array($emp_query)){ $id=$row['service_record_id']; $emp=$row['itemID']; ?>
<tr class="del<?php echo $id ?>">
<?php
$result=mysql_query("select * from item where itemID='2'")or die(mysql_error());
$row_emp=mysql_fetch_array($result);
?>
<td><?php echo $row['Nama']; ?></td>
<td><?php echo $row['Jenama']; ?></td>
<td><?php echo $row['Model']; ?></td>
<td><?php echo $row['No_Siri']; ?></td>
<td><?php echo $row['Tagging']; ?></td>
<td><?php echo $row['Tarikh_Diterima']; ?></td>
<td><?php echo $row['Remarks']; ?></td>
</tr>
<?php }?>
</tbody>
</table>
</center>
<br>
</br>
<br>
</br>
<?php
$result=mysql_query("select * from item where itemID='1'") or die(mysql_error());
$get_row=mysql_fetch_array($result);
?>
<?php echo $get_row['No']; ?>.<?php echo $get_row['Item']; ?> :<?php echo $get_row['Unit']; ?> unit
<br>
</br>
<center>
<table border="1" width="1000" height="80">
<thead>
<tr>
<th>Nama</th>
<th>Jenama</th>
<th>Model</th>
<th>No_Siri</th>
<th>Tagging</th>
<th>Tarikh_Diterima</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<?php
$emp_query=mysql_query("select * from service_record where itemID='1' order by Nama");
while($row=mysql_fetch_array($emp_query)){
$id=$row['service_record_id'];
$emp=$row['itemID'];
?>
<tr class="del<?php echo $id ?>">
<?php
$result=mysql_query("select * from item where itemID='1'")or die(mysql_error());
$row_emp=mysql_fetch_array($result);
?>
<td><?php echo $row['Nama']; ?></td>
<td><?php echo $row['Jenama']; ?></td>
<td><?php echo $row['Model']; ?></td>
<td><?php echo $row['No_Siri']; ?></td>
<td><?php echo $row['Tagging']; ?></td>
<td><?php echo $row['Tarikh_Diterima']; ?></td>
<td><?php echo $row['Remarks']; ?></td>
</tr>
は、iがアイテムID = 1、アイテムID = 2などによるいずれかによってコード1を書き。私はあなたがそれを維持する必要がある他のループ中に内部に保つことができるよりも唯一の1つの行のデータを持っている場合は、1つ
this is the example of picture that i want the output to display
何が問題なのですか。あなたは一番いい方法は何ですか? –
どこを閉じますか? –
コーディングでは、コーディングにどのように組み込むかわからないので、コーディングではループと配列を使用しませんでした。 – Hann