No it does not work on any of them. It only displays:
“Last played on week of. With a score of: to”
on every team.
I’m kind of at a loss at the moment… if your code is this:
[php]<?php
$query = "select selected.teamname AS selected_team, selected_score.score AS selected_score, week.week, year, home_id, ".
"target_score.score as target_score, target.teamname as targetname, week.ID ".
"from owners as selected ".
"JOIN game_scores AS selected_score ON selected.owner_id = selected_score.team_id ".
"JOIN game_setup ON game_setup.game_id = selected_score.game_id ".
"JOIN game_scores AS target_score ON target_score.game_id = game_setup.game_id AND target_score.team_id != selected_score.team_id ".
"JOIN owners AS target ON target.owner_id = target_score.team_id ".
"JOIN week ON week.week = game_setup.week ".
"WHERE selected.owner_id = $thing ".
"and target.active = 1 ".
"GROUP BY target.teamname, year, week.ID ";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ’ . mysql_error());
}
while($row = mysql_fetch_assoc($result))
{
if (!isset($t1)) { // Assign the team we’re looking up
$t1 = $row[‘selected_team’];
}
if (!in_array($row[‘targetname’], $t2)) { //create array of all opponents
$t2[] = $row[‘targetname’];
}
foreach ($t2 as $k => $v) { // get the array key of the opponent we are working with in this…
if $v = $row[‘targetname’] { // …instance of this loop
$key = $k;
}
}
// create array of scores, and last meeting using team $k as identifier
if ($row[‘selected_score’] < $row[‘target_score’]) {
$records[$key][‘losses’] = ($records[$key][‘losses’] + 1);
}
if ($row[‘selected_score’] == $row[‘target_score’]) {
$records[$key][‘draws’] = ($records[$key][‘draws’] + 1);
}
if ($row[‘selected_score’] > $row[‘target_score’]) {
$records[$key][‘wins’] = ($records[$key][‘wins’] + 1);
}
$records[$key][‘met’] = ("Last played on week " . $row[‘week’] . " of " . $row[‘year’] . “. With a score of: " . $row[‘selected_score’] . " to " . $row[‘target_score’]);
}
$num = (count($records) - 1);
for ($i=0; $i<=$num; $i++) { // correction $i must be zero, if we are getting an empty final field but still showing all information
// than we need to change $num as I did by subracting 1 from it 1 line up
$team2 = $t2[$i]; //changed the name of this variable so we don’t kill the array and changed it below to match
$w = $records[$i][‘wins’];
$l = $records[$i][‘losses’];
$d = $records[$i][‘draws’];
$m = $records[$i][‘met’];
if ($w === NULL){
$w = 0;
}
if ($l === NULL){
$l = 0;
}
if ($d === NULL){
$d = 0;
}
echo (”
" . $t1 . "
Opponent: |
" . $team2 . " |
Wins: " . $w . " Losses: " . $l . " Draws: " . $d . " |
|
" . $m . " |
");
}
?>[/php]
I see no reason it shouldn’t work, if everything else is… or at the very least we should have something like:
Last played on week of . With a score of $row[‘selected_score’] to $row[‘target_score’] as we know these variables are good as we’ve already used them…
Sabmin thank you very much.
I went and just re-copied your last post. I must have changed something at some point.
EVERYTHING WORKS PERFECTLY!!!
Thank you thank you thank you thank you thank you
Let me know where to mail the cookies to
Happy to help, my site is being a torrential pain in the butt, helps clear the mind to work on other code and help others.