What the function does is show a warning on the screen with the user name and a link to your profile, after a few seconds the notice is closed.
What the switch should do is show the information of the user 1 and at the end of the animation show the information of the user 2 but what it does in fact is to show the information of the first user and when the animation ends, show the information again from the first instead of the second.
What am I doing wrong?
function notificacion($connection, $usuario_id){
$usuario_sql = "SELECT * FROM usuario WHERE usuario_id = '$usuario_id'";
$usuario_resultado = mysqli_query($connection, $usuario_sql);
if ($usuario = $usuario_resultado->fetch_assoc()){
echo '
<a href="../usuario.php?id=' . $usuario['usuario_id'] . '">
<div id="notificacion2" title="Ver usuario">
<span class="usuario"><i class="fa fa-user ' . $usuario['usuario_nombre'] . '"></i></span>
</div><!-- notificacion --></a>
<script>
$("#notificacion2").delay(1000).animate({width: "toggle"}).delay(3000).fadeOut(1000);
</script>';
}
}
for ($i=0;$i<3;$i++){
switch ($i){
case 1:
// 1
notificacion($connection, 1);
break;
case 2:
// 2
notificacion($connection, 2);
break;
}
}