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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.