i can only get this to do the first entry in my table (which works correctly!), but then i get an error:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
however it successfully updates the first entry.
$result = mysql_query('SELECT table_id,first_name,last_name,one_points,two_points,three_points,four_points,five_points,six_points,seven_points,eight_points,nine_points,ten_points from table);
while ($row = mysql_fetch_assoc($result))
{
foreach ($row as $key => $value){
if (strstr($key, '_points')) {
$points[] = $value;
} }
rsort($points);
$total = 0;
for ($i = 0; $i < 7; $i++)
{
$total += $points[$i];
}
echo $row['first_name'] . ' ' . $row['last_name'] . '<br>
the total for the highest 7 values = ' . $total . '<br><br>';
$sql = "UPDATE table SET overall_seven='$total' WHERE table_id='$row[table_id]'";
$result = mysql_query($sql) or die('error: '. mysql_error());
}
is this looping properly?
-mike