All pastes #539040 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-06-05 05:12 UTC
rendered paste body
Table: combustsubmitters
Domain
bob.com
fred.com
hank.com

Table: combust
Domain | Clicks
bob.com/somestring | 10
www.bob.com/?5=erf9uf | 8
fred.com/aefsadf | 14
bob.com/435df | 1
hank.com/plsdf | 90

I want to take these results and combine the hits based on the domain
I can list them out obviously just fine I just can't figure out how to combine them

Here's my code so far:

$result = mysql_query("select * from combustsubmitters");
while($row = mysql_fetch_assoc($result)) {

$resultb = mysql_query("select id,linkurl,clicks from combust where link = '1' && linkurl like '%$row[domain]%'");
while($rowb = mysql_fetch_assoc($resultb)) {
$dateadd = date("j F Y", $rowb[dateadded]);

echo '<table width="120" cellspacing="0" border="0" bgcolor="ffffff" style="border-width:1px; border-style:solid; border-color:bbbbbb;"><tr><td>'.$rowb[id].',&nbsp;'.$rowb[linkurl].'</td></tr><tr><td colspan="2" bgcolor="f3f3f3"><b>Clicks: '.$rowb[clicks].'</b><br /></td></tr></table><Br />';
$i = $i + 1;
if ($i == 10) {
echo '</tr><tr>';
$i = 0;
}
}


}