How about, I'm trying to get the id
of the logged in user within a function to be able to create a query
(I do not know if the way I show it is correct).
What I've been up to now is this:
function obtener_notificaciones($conexion, $us){
$notu = $conexion->query("SELECT COUNT(*) FROM postula WHERE du_id = $us AND seen = 0");
$notu = $resultado->fetchAll();
return ($notu);
print_r($notu);
}
and I have another function to know if there is a session started which is the following:
function comprobarSession(){
if (!isset($_SESSION['usuario'])) {
header('Location: ' . RUTA . '/login.php');
}
else {
$us = $_SESSION['usuario'];
}
}
What I also want in case my function is correct, is to print the result of $notu
within a div
<li><a href="notificaciones.html"> Notificaciones (5)</a></li>
so you can replace (5)
with count
of query
where I want to show the count
is in lateral.php
in which I only have HTML e-books:
<div class="block-section text-center ">
<img src="images/<?php echo($_SESSION['usuario'][14]) ?>" class="img-rounded" alt="">
<div class="white-space-20"></div>
<h4><a href="perfil.php"><?php echo($_SESSION['usuario'][3]) ?></a></h4>
<div class="white-space-20"></div>
<ul class="list-unstyled">
<li><a href="mensajes.php"> Mensajes </a></li>
<li><a href="notificaciones.html"> Notificaciones (5)</a></li>
<li><a href="cambio.php"> Cambiar contraseña</a></li>
</ul>
<div class="white-space-20"></div>
</div>
</div>
<div class="col-md-9 col-sm-9">
<!-- Block side right -->
in the tags PHP
what I do is call the array of $_SESSION
and print the values of the array as can be seen, so with the function created above I want to change the (5)
by the result of the function that in this case if I'm not wrong would be $count