Jump to content

Sum of values


dpcampan

Recommended Posts

Hi all, can any of you wizards help me with a question. I am trying to make a pub quz scoreboard and i am a bit stuck totalling up the round scores. I have a table that stores 'teamid', 'teamname', and then their round scores 'round01', 'round02'..... 
I can pull all of this data out of the database and format as an html table but i'm stuck on getting their total score. I want it to be automatically generated from their round scores and dont want to have to input it manually.

Here is my code so far

 

 

 
  $query = "SELECT * from scoreboard ORDER BY teamid DESC";
$data = mysqli_query($dbc, $query);
 
 
  echo '<table align="center"
  table border="1"
  bordercolour="#00778f"
  cellpadding="5">';
echo '<tr>
<th>Team Name</th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>score</th>
</tr>';
  while ($row = mysqli_fetch_array($data)) 
  echo '
 
<td>' . $row['teamname'] . '</td>
<td>' . $row['round01'] . '</td>
<td>' . $row['round02'] . '</td>
<td>' . $row['round03'] . '</td>
<td>' . $row['round01'+'round02'+'round03'] . '</td>
 </tr>';
    
 
  echo '</table>'; 
 
i know that

 

<td>' . $row['round01'+'round02'+'round03'] . '</td>

 

is wrong but it gives you the idea of what i want it to do.

 

any help would be greatly appreciated.

Darren

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/277670-sum-of-values/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.