我要比较两个表。表1 目录 :
<table id='1'>
<tr>
<td>Account No1</td>
<tr>
<?php
$query="SELECT * FROM temp";
if($query_run=mysql_query($query))
{
while($row=mysql_fetch_array($query_run))
{
?>
<td ><?php echo $DESCRIPT=$row['ACCOUNTNO'];?></td>
<?php
}
}
?>
</table>
表2:代码
<table id='2'>
<tr>
<td >Account No2</td>
<td>status</td>
</tr>
<tr>
<?php
$query="SELECT * FROM temp2 ";
if($query_run=mysql_query($query))
{
while($row=mysql_fetch_assoc($query_run))
{
echo '<tr id="ite'.$row["ACCOUNTNO"].'">';
?>
<td ><?php echo $DESCRIPT=$row['ACCOUNTNO'];?></td>
<td ><?php echo $DESCRIPT=$row['status'];?></td>
<?php
}
}
?>
<input type="SUBMIT" class="btnStyle" value="cHECK">
它将显示如下结果:
--------------------------------------------
Account no1 Account no2 Status
--------------------------------------------
000005 000005 L
000007 000007 L
8888888 0000089 A
0000003 A
9999999 L
不,我想要 如果帐户编号 1 == 帐户编号 no2 且帐户编号 1 的状态为 A,则将显示红色记录。
或者我想要显示 Acoountno1 整行红色的查询,如果 staus 是"A"并且帐户编号为 1 == acoount no2
如果您想了解更多信息,请告诉我。
使用此更新的代码
<style>
.red_color, .red_color td{ color: red; }
</style>
<table >
<tr>
<td >Account No1</td>
<td >Account No2</td>
<td>status</td>
</tr>
<tr>
<?php
$query="select temp1.ACCOUNTNO as a1, temp2.ACCOUNTNO as a2, temp2.status from temp1 inner join temp2 on temp1.ACCOUNTNO = temp2.ACCOUNTNO where temp2.status in ('A','L') ";
if($query_run=mysql_query($query))
{
while($row=mysql_fetch_assoc($query_run))
{
?>
<tr id = "ite<?php echo $row["a1"]; ?>" class = " <?php if($row['status'] == 'A') { echo "red_color" ; } ?>" >
<td ><?php echo $row['a1'];?></td>
<td ><?php echo $row['a2'];?></td>
<td ><?php echo $row['status'];?></td>
</tr>
<?php
}
}
?>
</table>