我需要为一个部分(vechile)过滤数据,但是它取得与之相关的所有结果而不是客户明智的PID。我的代码是 我哪里错了?
<?php
$sql="SELECT DISTINCT(PARTNO) FROM `paidamount` ORDER BY `PARTNO`";
$res=mysql_query($sql);
$num=mysql_num_rows($res);
if($num>0)
{
while($fetch=mysql_fetch_array($res))
{
?>
<tr>
<td colspan="15" align="left" style="background-color:#006699;"><p style=" color:#FFFFFF;"><strong><?php echo $fetch['PARTNO']?></strong></p></td>
</tr>
<?php
$sql="SELECT * FROM paidamount where paidamount.PARTNO='".$fetch['PARTNO']."' ORDER BY PARTNO";
//$sql="SELECT * FROM `paidamount`";
$result=mysql_query($sql);
$numrow=mysql_num_rows($result);
$i=1;
while($rows=mysql_fetch_array($result))
{
//echo $rows['id'];
$imid=explode(",",$rows['issued_med']);
$pmid=explode(",",$rows['ffffff']);
?>
答案 0 :(得分:0)
替换
$sql="SELECT DISTINCT(PARTNO) FROM `paidamount` ORDER BY `PARTNO`";
此查询与以下查询: -
$sql="SELECT DISTINCT(PARTNO) as PARTNO FROM `paidamount` ORDER BY `PARTNO`";