그러나 문제를 해결할 수 있었는데, 내 client_id를 에코 할 때 많은 반복이 있었고 array_unique와 distinct를 넣으려고했지만 아무것도 할 수 없었습니다. 그 밖에 내가 할 수있는 것이 있습니까? 또한 일부 클라이언트에는 둘 이상의 주소가 있기 때문에 모든 주소를 표시하려고합니다.배열의 출력을 어떻게 구별합니까?
$query1= "Select distinct client_id from client_profile where client_status= 'f'";
$result1= pg_query($conn2, $query1);
$clientid = array();
while($row1 = pg_fetch_array($result1)){
$id=$row1['client_id'];
$clientid[]=$id;
$clientid = array_unique($clientid);
}
//$clientid=array_unique($clientid);
$clientid=implode(',',$clientid);
$query= "select * from vouchers where client_id IN ($clientid)";
$result = pg_query($conn,$query);
?>
<!DOCTYPE html>
<html>
<head>
<title>Inactive Clients</title>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<link href = "http://fonts.googleapis.com/css?family=Roboto:400">
</head>
<body>
<table class="table table-sm">
<thead>
<tr>
<th>Client id</th>
<th>File Name</th>
</tr>
</thead>
<?php
while($row = pg_fetch_array($result))
{
?>
<tbody>
<tr>
<td><?php echo $row['client_id']; ?></td>
<td><?php echo $row['file_name']; ?></td>
</tr>
<?php }?> </tbody>
</table>
</body>
</html>
어떤 쿼리에서 반복이 발생합니까? 두 번째 쿼리는 첫 번째 쿼리가 아닌 바우처를 확인하는 것입니다. 첫 번째는 잘 작동해야합니다. 또한 값을 고유하게하려는 테이블에서 UNIQUE를 사용해야합니다 (이 경우 client_id는 client_profile에서 고유해야하며 그 다음에 DISTINCT를 사용할 필요가 없습니다). – Janno