Hello All,
I am a beginner trying to make things happen. My skills are definitely low, but I am trying to improve. I am working on a standings page that will do the following:
I am joining 3 tables to gather information. Username, Week, Winning Result, User Pick, and Assigned Points
I am then looking at Winning Result, and if that is equal to User Pick, then Assign points
I am looking for an outcome to do the following columns:
1.) Rank (counter of 1 through how many distinct users in a specific table)
2.) Username
3.) Total points for all combined weeks
4. - 21) Week by week results.
Basically, calculate how many points each user gets for each week and a total of all weeks combined.
Here is the code I am working on (I can get one row to display, but and some of the data looks correct)
Can anyone help with this?
Thanks,
Patsman77
$base1 = "select DISTINCT username FROM allpoints";
$resultOrig1 = mysql_query($base1);
$currentnum = 0;
$numrows = mysql_num_rows($resultOrig1);
$i=0;
while ($baseRes=mysql_fetch_object($resultOrig))
{
$user = $baseRes->username;
$SumWeely = 0;
$sumTotal = 0;
$i++;
for ($currWeek=1; $currWeek<=2; $currWeek++)
{
$sql = "
SELECT allpoints.username,phpfb_picks.pick,allpoints.value,phpfb_schedule.result,phpfb_schedule.gameid
FROM `allpoints`
left join
phpfb_picks on allpoints.gameid = phpfb_picks.gameid
left join
phpfb_schedule on phpfb_picks.gameid = phpfb_schedule.gameid
WHERE
phpfb_schedule.week = '".$currWeek."'
and
allpoints.username ='". $user ."'
and
phpfb_picks.user ='". $user ."'";
$result = mysql_query($sql) or die (mysql_error());
while($row = mysql_fetch_object($result)) {
if($row->pick == $row->result )
{
$SumWeely = $row->value;
}
}
$sumTotal+= $SumWeely+$SumWeely;
}
}
?>
<tr><td><?php echo $i; ?></td><td><?php echo $user; ?></td><td><?php echo $sumTotal; ?></td><td><?php echo $SumWeely; ?></td></tr>
</table>