I have a table in mysql with three fields idPago value mespago. In it I have some data and I want to make a query by mespago, that when selecting the month in the datapicker I show in a table the sum of value only of those that belong to the selected month. I have this.
//Acá seleccione el mes
<input type="text" id="mespago" name="mespago" class="form-control"
<?php $sumapormes = pagoData::pormes("valor");
echo $sumapormes->sum;?>/>
//Esta es la tabla donde quiero mostrar la suma del valor del mes seleccionado
<div class="box-body">
<?php if (count($reporte)>0): ?>
<table class="table table-bordered table-hover">
<thead id="cabe">
<th>Suma por mes</th>
</thead>
<tr>
<td><?php $apostadoSuma = pagoData::sumar("valor");
echo $apostadoSuma->suma;?>
</td>
</tr>
</table>
<?php else: ?>
<p class="alert alert-warning">No Se Encontraron Datos</p>
<?php endif; ?>
</div>
//La función que tengo para que me busque por mes
public static function pormes($valor) {
$sql="select SUM($valor) AS sum FROM ".self::$tablename." where mespago=$mespago";
$query = Executor::doit($sql);
return Model::one($query[0],new pagoData());
}
But it does not show me anything when selecting somemes