SmEdD
12-02-2003, 01:56 AM
Is there a way to keep from having to run the same query 2 times?
$games = $DB_site->query("
SELECT *
FROM " . TABLE_PREFIX . "clan_game
ORDER BY displayorder
");
while ($game = $DB_site->fetch_array($games))
{
globalize($_POST, array("game_$game[gameid]", "game_$game[gameid]" . '_opt'));
$gamenames .= ', roster.game_' . $game['gameid'];
}
unset($game);
unset($games);
$memberinfo = $DB_site->query_first("
SELECT
roster.memberid, roster.callsign, roster.firstname, roster.lastname, roster.birthday, roster.rank, roster.email, roster.status, roster.location,
rank.title$gamenames
FROM " . TABLE_PREFIX . "clan_roster AS roster
LEFT JOIN " . TABLE_PREFIX . "clan_rank AS rank ON(rank.level = roster.rank)
WHERE roster.memberid = $memberid
");
// Generate Games
$games = $DB_site->query("
SELECT *
FROM " . TABLE_PREFIX . "clan_game
ORDER BY displayorder
");
while ($game = $DB_site->fetch_array($games))
{
$name = 'game_' . $game['gameid'];
if ($memberinfo["$name"] == 1)
{
$memberinfo['games'] .= $game['title'] . '<br />';
}
}
$games = $DB_site->query("
SELECT *
FROM " . TABLE_PREFIX . "clan_game
ORDER BY displayorder
");
while ($game = $DB_site->fetch_array($games))
{
globalize($_POST, array("game_$game[gameid]", "game_$game[gameid]" . '_opt'));
$gamenames .= ', roster.game_' . $game['gameid'];
}
unset($game);
unset($games);
$memberinfo = $DB_site->query_first("
SELECT
roster.memberid, roster.callsign, roster.firstname, roster.lastname, roster.birthday, roster.rank, roster.email, roster.status, roster.location,
rank.title$gamenames
FROM " . TABLE_PREFIX . "clan_roster AS roster
LEFT JOIN " . TABLE_PREFIX . "clan_rank AS rank ON(rank.level = roster.rank)
WHERE roster.memberid = $memberid
");
// Generate Games
$games = $DB_site->query("
SELECT *
FROM " . TABLE_PREFIX . "clan_game
ORDER BY displayorder
");
while ($game = $DB_site->fetch_array($games))
{
$name = 'game_' . $game['gameid'];
if ($memberinfo["$name"] == 1)
{
$memberinfo['games'] .= $game['title'] . '<br />';
}
}