我有以下代码:
$query = "SELECT ads.*,
trafficsource.name AS trafficsource,
trafficsource.id AS trafficsourse_id,
FROM ads
JOIN trafficsource ON ads.trafficsourceId = trafficsource.id
WHERE advertiserId = '$advertiser_id'";
$mysqli = new mysqli();
$mysqli->connect('localhost', 'root', '', 'adsbase');
$result = $mysqli->query($query);
while ($row = $result->fetch_assoc()) {
echo "<h2>Traffic Sources: {$row['trafficsource']}</h2>";
}
此代码显示的结果如下:
Traffic Sources: Example1
Traffic Sources: Example2
Traffic Sources: Example2
Traffic Sources: Example1
Traffic Sources: Example2
Traffic Sources: Example1
我想要并且无法弄清楚的是显示如下结果:
Traffic Sources: Example1, Example2
所以没有重复,也都在一行中。