0
I am trying to use wildcard character as query criterion in my query, however the result is returned empty.
include_once(".. /inc/conexion.php");
$lj = "4";
$linha = isset($_GET['ans'])?$_GET['ans']:"";
$data = date("d-m-Y");
$partes = explode("-", $data);
$ano = $partes[2];
$periodo = "$ano%";
$sql = "SELECT sjy_vendas.tipo, Sum(sjy_vendas.qt) AS qt, Sum(sjy_vendas.qtv) AS qtv, Sum(sjy_vendas.rprd) AS rprd, Sum(sjy_vendas.rsrv) AS rsrv, Sum(sjy_vendas.tprd) AS tprd, Sum(sjy_vendas.tsrv) AS tsrv, Sum(sjy_vendas.vlr_compra) AS vlr_compra
FROM sjy_vendas
WHERE sjy_vendas.empresa = $lj
AND sjy_vendas.tipo = $linha
AND dt_nf CONCAT('%',:param,'%')
GROUP BY sjy_vendas.tipo";
$sql->bindParam(':param',$ano);
$consulta = mysqli_query($conexao,$sql);
while($dados = mysqli_fetch_array($consulta)){
$qtv = $dados['qtv'];
$rprd = $dados['rprd'];
}
echo "Quantidade: " . $qtv . "<br />";
echo "Receita: " . $rprd . "<br />";
Thanks for the reply Evandro, but now is returning the error Fatal error: Call to a Member Function bindParam() on a non-object in D: xampp htdocs final views premorc.php on line 2705. I’ll edit the question to put the code I’m using.
– Webster Moitinho