Tengo la siguiente funcion que me cuenta los tickets donde los tipo de solicitud sean iguales a 2 o a 5.
function cuentaticketspendienteempleado($conexion){
$pendientes = (mysqli_query($conexion, "SELECT COUNT(*) AS conteo FROM ticket WHERE tipo_solicitud AND (status ='2' or status ='5' )")) or die("Error mostrando tickets pendientes: ".mysqli_error($conexion));
$resultados = mysqli_fetch_row($pendientes);
return $resultados[0];
}
What I want to implement is an account but only of the tickets that are related to the user's department_id.
I try to do it with the following function by adding the id parameter obtained in the search.
function cuentaticketspendienteempleado($conexion, $id){
$consulta = mysqli_query($conexion, "SELECT *, COUNT(t.id) as contador_tickets, t.id as id_ticket, u.id as user_id, t.fecha_creacion as t_fcreacion, t.hora_creacion as t_hcreacion
FROM ticket as t
JOIN usuario AS u
ON t.id_usuario = u.id
WHERE t.status <> '3' AND u.id_departamento = ".$id."")
or die("Error listando Ticket: ".mysqli_error($conexion));
return $consulta;
}
But I have the following error ... What would be the error?
Thank you.
I show the result like this
<?php
$resultados = $ticket->cuentaticketspendienteempleado($conexion,$id);
if($resultados > 0) // validamos si es mayor a 0
{
echo '<div id="notificacion">',$resultados,'</div> ';
}else{
echo 'GG';
} ?>