1
I have a Side Menu on my page and I want to display an alert text to the user, indicating when they have new messages and how many of them. For this I made the query in BD and it returns me correctly the amount of records based on the query I assembled.
The problem is when I insert in 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 intention is to store the result of the query 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 the number two, but in this code returns nothing. Someone can tell me why?
Note: I made it in PHP and Mysql