Code:
SELECT
ID,
website,
(SELECT COUNT(IP) FROM traffic WHERE TO_DAYS(NOW()) - TO_DAYS(day) < 7) AS hitCount,
(SELECT COUNT(DISTINCT(IP)) FROM traffic WHERE TO_DAYS(NOW()) - TO_DAYS(day) < 7) AS uniqueCount
FROM
traffic
Requires MySQL 4.1 or higher. That would give you all your websites along with the counts you want in a single query, and it'll be much faster than performing 3 separate queries.
Off Topic:
You should probably use DATE_SUB instead of TO_DAYS but I'm not comfortable enough with that function to write an untested example.
Bookmarks