Ahhh...yes, I see that.
The problem occurs because, again, your DB isn't normalized. If it were, you would have a separate CATEGORIES table, where each category had a categoryid (INT PRIMARY KEY) and cateogoryname. And then, in your OFFERS table, you would use the categoryid instead of the name. You really should read up on NORMALIZATION. Your lack of it is causing you all sorts of efficiency griefs.
So lacking that separate CATEGORIES table...
We could fix it by just changing the first SELECT to SELECT DISTINCT, but that won't be efficient.
So try this...
Code:
$sql = "SELECT OS.category, IFNULL(SS.thecount, 0) AS howmany "
. " FROM ( SELECT DISTINCT category FROM offers ) AS OS "
. " LEFT JOIN ( "
. " SELECT O.category, COUNT(*) AS thecount "
. " FROM offers AS O LEFT JOIN completed_offers AS C"
. " ON ( O.offerid = C.offerid AND C.username='$usr' ) "
. " WHERE O.countries LIKE '%$country%' "
. " AND C.offerid IS NULL "
. " GROUP BY O.category ) AS SS "
. " ON OS.category = SS.category "
. " ORDER BY OS.category";
If it's not obvious,
SELECT DISTINCT category FROM offers is, essentially, building the missing CATEGORIES table. But it's a much more expensive operation than if you actually had such a table.