I'm adding two fields and everything works fine. The problem is that I do not know how to subtract those two values to find the difference, because the values of Cant. Bet and Cant. Won calculate them by means of a function each and I want to show the difference in the red box of the image. / p>
Functions with which I sumo
public static function sumar($apostado) {
$sql="select SUM($apostado) AS suma FROM ".self::$tablename;
$query = Executor::doit($sql);
return Model::one($query[0],new apuestaData());
}
public static function sumarg($ganado) {
$sql="select SUM($ganado) AS sumag FROM ".self::$tablename;
$query = Executor::doit($sql);
return Model::one($query[0],new apuestaData());
}
I create the table and load the data
<div class="box-body">
<?php if (count($reporte)>0): ?>
<table class="table table-bordered table-hover">
<thead id="cabe">
<th>Cant. Apostado</th>
<th>Cant. Ganado</th>
<th>Ganancias</th>
</thead>
<tr>
<td><?php $apostadoSuma = apuestaData::sumar("apostado");
echo $apostadoSuma->suma;?>
</td>
<td><?php $apostadoSuma = apuestaData::sumarg("ganado");
echo $apostadoSuma->sumag;?>
</td>
</tr>
</table>
<?php else: ?>
<p class="alert alert-warning">No Se Encontraron Datos</p>
<?php endif; ?>
</div>
Someone can help me ...