you got me worng
i did this query
PHP Code:
$teamslist = $DB_site->query("
SELECT teams.*,user.username AS username,
user.userid AS userid ,user.posts AS userposts,
user.reputation AS userrep,
COUNT(user.posts) AS totalteamposts,
COUNT(user.reputation) AS totalteamrep
FROM " . TABLE_PREFIX . "teams AS teams
LEFT JOIN user ON(teams.teamid = user.teamid)
WHERE teams.teamid > 1
GROUP BY teams.teamid
");
while ($teams = $DB_site->fetch_array($teamslist))
{
eval('$teamsbit .= "' . fetch_template('teams_teamslistbit') . '";');
}
now in table teams i got teamposts
so i want to update teams.teamposts
now the value of total team posts is in
$teams['totalteamposts']
now my qustion is
if there a way to update teams.teamposts=$teams['totalteamposts']
without exstra query
or if i must use exstra query
do i need to run the query for each team (in the while loop)
so code should look like that
PHP Code:
$teamslist = $DB_site->query("
SELECT teams.*,user.username AS username,
user.userid AS userid ,user.posts AS userposts,
user.reputation AS userrep,
COUNT(user.posts) AS totalteamposts,
COUNT(user.reputation) AS totalteamrep
FROM " . TABLE_PREFIX . "teams AS teams
LEFT JOIN user ON(teams.teamid = user.teamid)
WHERE teams.teamid > 1
GROUP BY teams.teamid
");
while ($teams = $DB_site->fetch_array($teamslist))
{
$DB_site->query_first("UPDATE teams SET teamposts=$teams[totalteamposts] WHERE teamid=$teamid ");
eval('$teamsbit .= "' . fetch_template('teams_teamslistbit') . '";');
}
if i do it this way so i add 1 exstra query for each team
if i got 100 teams i add 100 query's
something i dont want to do
so im looking for other way...
any ideas ?