I have a MySQL query that is returning the results that I need correctly. However, I want to clean up the output a bit for my specific use case. Specifically, I'd like to remove a column from the output so that it only appears the first time it's pulled from the database. Here's a quick example of the type of output I'm getting:
Campaign A - asset 1
Campaign A - asset 2
Campaign A - asset 3
Campaign B - asset 1
Campaign B - asset 3
Campaign C - asset 2
Campaign D - asset 1
Campaign D - asset 2
etc
This is what I'd like instead:
Campaign A
asset 1
asset 2
asset 3
Campaign B
asset 1
asset 3
Campaign C
asset 2
Campaign D
asset 1
asset 2
So, basically, I just want to see the "Campaign A" title once, even though it's part of the record of workshops.
Here's the php code that I'm working with (in this case, "campaigntitle" is the column I only want to see once per group. "assettitle" would be shown in every row returned by the query) :
<?php do { ?>
<tr>
<td><a href="detail-nd.php?recordID=<?php echo $row_assetslist['assetid']; ?>"> Details</a> <a href="assetupdate-nd.php?recordID=<?php echo $row_assetslist['assetid']; ?>">edit</a> delete</td>
<td><?php echo $row_campaignassetjoin['campaigntitle']; ?></td>
<td><?php echo $row_campaignassetjoin['assettitle']; ?></td>
<td><?php echo $row_campaignassetjoin['assettype']; ?></td>
</tr>
<?php } while ($row_campaignassetjoin = mysql_fetch_assoc($campaignassetjoin)); ?>
here's the pertinent mysql query in the document header:
mysql_select_db($database_campaignarchive, $campaignarchive);
$query_campaignassetjoin = "SELECT assets.*, campaign.* FROM campaign JOIN assets ON assets.campaignid=campaign.campaignid ORDER BY campaign.campaignid DESC";
$campaignassetjoin = mysql_query($query_campaignassetjoin, $campaignarchive) or die(mysql_error());
$row_campaignassetjoin = mysql_fetch_assoc($campaignassetjoin);
$totalRows_campaignassetjoin = mysql_num_rows($campaignassetjoin);