<?php
error_reporting(E_ALL);
ini_set('display_errors' ,1);
require "connection.php";
$query= "SELECT client_id, array_agg(insurance) AS insurance from vouchers WHERE parsing_date=CURRENT_DATE GROUP BY client_id ";
$result = pg_query($conn,$query);
?>
<!DOCTYPE html>
<html>
<head>
<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">
<style>
.responstable {
margin: 1em 0;
width: 100%;
overflow: hidden;
background: #FFF;
color: #024457;
border-radius: 10px;
border: 1px solid #167F92;
word-wrap: break-word;
}
</style>
</head>
<body>
<div class="container-fluid">
<div>
<h1>Clients</h1>
</div>
<table class="responstable" rules='all' style='border-collapse: collapse;'>
<thead>
<tr>
<th>Client id</th>
<th>Insurance</th>
<th>Number of rows</th>
</tr>
</thead>
<?php
while($row = pg_fetch_array($result))
{
?>
<tbody>
<td><?php echo $row['client_id']; ?></td>
<td><?php echo $row['insurance']; ?></td>
<td><?php echo $row['rows'];?></td>
</tr>
<?php }
?> </tbody>
</table>
</div>
</body>
</html>
私はから私の出力を作るために上記のコードを持ってそれを修正する方法を、私はアドオンを試してみましたグループ化特定の行が一緒に
Client id Number of rows Insurance
------------ ----------------------- --------------
123 3 rows AA,EE,U
125 2 rows AA,UE
126 1 rows CU
124 1 rows UE
イムわかりませんこの行を検索クエリに入力してください:
concat(count(*), ' rows') AS rows
ロー、私は行が出てくるために何ができるかについてのアイデアと "{"と ""は行く?
を解決している、私はそれを試してみました、私はこのエラーが発生しました:警告:pg_query():クエリが失敗しました:ERROR:concat(bigint、unknown)関数が存在しませんLINE 1:SELECT client_id、concat(count(*)、 'rows')AS行、array_agg ... ^ヒント:いいえ関数は指定された名前と引数の型と一致します。明示的な型キャストを追加する必要があるかもしれません。 in index.php in line 8 –
また、PostgreSQLを使用しているImが通常のSQLでないことを確認できます –
更新された回答を確認 – Sundar