I have a Side Menu on my page and I want to display a warning text for the user, indicating when he has new messages and how many. For this I did the query in the DB and it correctly returns the number of records based on the query I set up.
The problem is when I enter the code, because it is not returning any data. I did so:
if ($usuario->getCodEquipe() == 1 ) {
$dbc = mysql_connect('localhost', 'root', '', 'nome_banco');
$query = "SELECT count(*) FROM FaleConosco WHERE status = '0' ";
$result = mysql_query($dbc, $query);
echo " <hr>\n";
echo " <li>\n";
echo " <h3><span class=\"icon-comunicacao\"></span>Comunicação</h3>\n";
echo " <ul>\n";
echo " <li class=\"btn-voltar\">Voltar</li>\n";
echo " <li><a href=\"#\">Administrar Notícias</a></li>\n";
echo " <hr>\n";
echo " <li><a href=\"#\">Moderar Comentários</a></li>\n";
echo " <hr>\n";
echo " <li><a href=\"#\">QVT</a></li>\n";
echo " <hr>\n";
echo " <li><a href=\"#\">Fale Conosco";
if($result != 0)
{
echo " - <b>$result Nova(s)</b>";
mysql_close($dbc);
}
echo " </a></ul>\n";
echo " </li>\n";
}
The intent is to store the query result in a variable, and in the if of the code I compare the value and display the alert. Using the query directly in the database, it works and returns me number two, but in this code it returns nothing. Can anyone tell me the reason?
Note: I did in PHP and MySQL