I have a query in a table that should return the value of the number of records found that meet a given requirement.
The code:
<?php
require('conn.php');
$prevJan= "SELECT COUNT(ID) AS PrevJan FROM participantes WHERE PREVISTO = 'Previsto' and FORMACAO = 'Revues Technique' and MES = 'jan' and AREA = 'R&D'";
$realJan= "SELECT COUNT(ID) AS RealJan FROM participantes WHERE REALIZADO = 'Realizado' and FORMACAO = 'Revues Technique' and MES = 'jan' and AREA = 'R&D'";
$consultapj = mysqli_query($prevJan);
$consultarj = mysqli_query($realJan);
var_dump($consultapj);
?>
The connection:
<?php
$connection = mysqli_connect("localhost", "root", "", "db_formacao");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
If I make a query like this by phpMyAdmin, fine, it returns the right value, however, if when I try to print the value on my page php, printa NULL.
Also, I want to get this value and put it as an item in a list, see:
data: [<?php echo($consultarj);?>]
Does anyone have an idea of what might be happening?