I have a table 'tblexam' which contains State,city,candidate.I want to fetch the data from this table using where clause.I am able to fetch the data but i want to add the sum of Candidate at the last row(As Shown In Picture) how can i do that . 

```
$sql="SELECT * 
      FROM tblexam
      WHERE state='UP'";

$cnt=1;
if($query->rowCount() > 0)
{
    foreach($results as $result) {      
        $cnt=$cnt+1; ?>                                      
        <tr class="odd gradeX">
        <td class="center"><?php echo htmlentities($cnt);?></td>
        <td class="left"align="left"><?php echo htmlentities($result->state);?></td>
        <td class="center" align="left"><?php echo htmlentities($result->city);?></td>
        <td class="center"align="left"><?php echo htmlentities($result->candidate);?></td>
   <?php } ?>                       
        <td class="center"align="left"><?php echo htmlentities($result->Total);?></td>

    </tbody>
 </table>

```

[![enter image description here](https://i.stack.imgur.com/cBSSm.jpg)](https://i.stack.imgur.com/cBSSm.jpg)