Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. public function verMensajesUsuario($usuario){
  2. $conexion = $this->c->conectar();
  3.  
  4. $sql = "SELECT mensajes.id, titulo,contenido,createAt, usuario
  5. FROM mensajes,usuarios
  6. WHERE mensajes.creador = usuarios.id AND usuarios.usuario = '$usuario';";
  7.  
  8.  
  9.  
  10. $result = mysqli_query($conexion,$sql);
  11.  
  12. if ($result->num_rows > 0) {
  13. return $result;
  14. }
  15. else{
  16. return false;
  17. }
  18.  
  19. }
  20.  
  21. <?php
  22. if (!isset($_SESSION['usuario'])) {
  23. header('location: ../login.php');
  24. }
  25.  
  26. require_once 'conexion.php';
  27. require_once 'controllers/mensaje.php';
  28.  
  29. //esto no hace falta pero para que quede modularizado
  30. $usuario =$_SESSION['usuario'];
  31.  
  32.  
  33. $mensaje_controllers = new Mensaje();
  34.  
  35. $result = $mensaje_controllers->verMensajesUsuario($usuario);
  36. var_dump($result);
  37.  
  38. $array_mensajes = $result->fetch_array();
  39.  
  40. var_dump($array_mensajes);
  41.  
  42.  
  43.  
  44.  
  45.  
  46. ?>
  47.  
  48. 0 => string '6' (length=1)
  49. 'id' => string '6' (length=1)
  50. 1 => string 'titulo de jose ' (length=15)
  51. 'titulo' => string 'titulo de jose ' (length=15)
  52. 2 => string 'contenido de jose' (length=17)
  53. 'contenido' => string 'contenido de jose' (length=17)
  54. 3 => string '2019-04-20 17:47:40' (length=19)
  55. 'createAt' => string '2019-04-20 17:47:40' (length=19)
  56. 4 => string 'jose' (length=4)
  57. 'usuario' => string 'jose' (length=4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement