show all the contents of a story by clicking on the title - php

0

I have this code, and what I could only achieve is to show the content of the news below all the div that contains the titles, and I would like it to be displayed in a new tab so that the site is better organized. It's a bit messy, but if you could help me I'd appreciate it.

<?php
session_start();
require "conexion.php";
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="../css/estilo.css">
    <title>Home</title>
  </head>
  <body>
    <header>
      <div class="header">
        <nav>
          <ul>
            <li><a href="index.php">Inicio</a></li>
            <li><a href="perfil.php">Perfil</a></li>
            <?php if($_SESSION['jerarquia'] == 1){?>
              <li><a href="panel_admin.php">Panel</a></li>
            <li><a href="cerrar_sesion.php">Cerrar Sesion</a></li>
            <?php } ?>
          </ul>
        </nav>
        <div class="bienvenido">
          <?php
            if(isset($_SESSION['username'])){echo "<p>Bienvenido, " . $_SESSION['username'] .", nivel: ".$_SESSION['jerarquia']."</p>";}
            else{echo "<a href='inicio_sesion.php'>Inicia sesion</a> | <a href='registro.php'>Registrate</a>";}
          ?>
        </div>
      </div>
    </header>
    <section class="container">
      <div class="menu-dos">
        <nav>
          <ul>
            <li><a href="agregar_entrada.php">Agregar entrada</a></li>
            <li><a href="modificar_entrada.php">Modificar entrada</a></li>
            <li><a href="eliminar_entrada.php">Eliminar entrada</a></li>
          </ul>
        </nav>
      </div>
      <div class="main-entradas">
      <p class="titulo">Entradas</p>
	  <hr>
        <?php
            $consulta_mostrar_entradas = $db->prepare("SELECT * FROM entradas ORDER BY id DESC");
            $consulta_mostrar_entradas->execute();

            $total = $consulta_mostrar_entradas->rowCount();
            if($total > 0)
            {
              while($mostrar_entradas = $consulta_mostrar_entradas->fetch(PDO::FETCH_ASSOC))
              {
                echo '<a href="?entrada='.$mostrar_entradas['id'].'">'.$mostrar_entradas['titulo'].'</a><br>
                      <p>Autor: ' . $mostrar_entradas['autor'] . '</p><br><hr> ';
              }
              if(isset($_GET['entrada']))
              {
                $consulta_texto = $db->prepare("SELECT * FROM entradas WHERE id = ?");
                $consulta_texto->execute(array($_GET['entrada']));
                $texto = $consulta_texto->fetch(PDO::FETCH_ASSOC);

                echo '<p>'.$texto['texto'].'</p>';
              }

            } else {echo "No hay entradas";}
            ?>
      </div>
    </section>
  </body>
</html>
    
asked by federico 23.03.2018 в 21:17
source

0 answers