1
我試圖讓我的數據看起來像下面的輸出。我有一個內部連接到一個SQL連接到 連接兩個表,所以他們將輸出的數據,所以它看起來像下面。我不知道如何做到這一點可能有人給我一個例子創建內部連接以創建適當的輸出
這是輸出的樣子現在
First American
2014-03-17 Blackwell Vancouver 115
First American
2014-04-21 Kurth Vancouver 85
Title Source
2014-01-04 Kurth Vancouver 85
Title Source
2014-03-11 Kurth Vancouver 85
Title Source
2014-03-17 Kurth Vancouver 85
這是我想它是什麼樣子
First American
2014-03-17 Blackwell Vancouver 115
2014-04-21 Kurth Vancouver 85
Title Source
2014-01-04 Kurth Vancouver 85
2014-03-11 Kurth Vancouver 85
2014-03-17 Kurth Vancouver 85
$result = $db->query("SELECT customers.name,signings.pid,signings.done,signings.signstart,
signings.lname,signings.ordern, signings.city,signings.samount,signings.prtamount,
signings.faxamount FROM customers Inner Join signings On signings.custid = customers.custid
WHERE signings.pid = 6 AND signings.done = 1 GROUP BY customers.name, signings.pid,
signings.done,signings.signstart");
foreach($result as $key => $income) {
echo $income['name'];
echo '<br>';
$total = $income['samount'] + $income['prtamount'] + $income['faxamount'];
echo $income['signstart'] . ' ' .$income['lname']. ' ' .$income['city'] . ' ' .$total;
echo '<br>';
}
這很完美。非常感謝 –