Show html page through index.php funcion.php

-1

I explain myself because the title might be a bit long and I wanted to simplify it.

I have a index.php page, it has a table, where in a tr , td ( height and width already established) has a include ('/funciones/cargar_entrada.php') , so The content of this include will be displayed in est tr , td .

The function carga_entrada.php , connects to a BBDD and retrieves the last entry (Example: entrada1.html ). I have tried to show entrada1.html testing with;

  • include
  • echo "< a href='/../entradas/entrada1.html'>< /a>";
  • <script type="text/javascript"> location.href='/../entradas/entrada1.html'; </script>
  • So far everything is fine. The fact is that it does not show the content of entrada.1html in cargar_entrada.php ...

    Code of upload_input.php

      

    $ server=""; $ user=""; $ pass=""; $ bbdd="";

         

    $ connection = mysqli_connect ($ server, $ user, $ pass, $ bbdd) or die   ("Error 505 NOT FOUND");

         

    $ sql="SELECT * FROM entries ORDER BY id DESC LIMIT 1";   $ table = mysqli_query ($ connection, $ sql);

         

    while ($ row = mysqli_fetch_object ($ table)) {$ id = $ row-> id; }

         

    header ('Location: ../ entries / entry'. $ id. '. html');

    I know it's very basic but it works correctly

    Edit: In the end I opted for the following.

    In index.php I have created an iframe with src = upload_entry.php, and this with the code that I have put above, loads the last entry correctly.

    Topic solved, thanks for the help!

        
    asked by Akarin 02.09.2016 в 18:47
    source

    1 answer

    1

    You say you have tried in three different ways to show the contents of a html document within a cell ( <td></td> ) of a table.

    Well, your first attempt was using " include ":

    Tell you that you are doing the right thing, but you should know that the "include" directive is limited to "include" the content of the file that you indicate. You comment that:

      

    "The function carga_entrada.php, connects to a BBDD and retrieves the   Last entry (Example: input1.html). "

    I understand that you mean that you have a file " cargar_entrada.php " in which you have a function called " cargar_entrada() " that makes a query to a BBDD and retrieves the name of the file in which the code is html of the last entry. Tell you that you should not only declare and define the function " cargar_entrada() " in this way:

    function cargar_entrada()
    {
        // Consulta a BBDD y retorno del nombre del archivo con la última entrda
        return $ruta_archivo;
    }
    

    If not that you have to invoke it somewhere or in the file upload_entry.php:

    function cargar_entrada()
    {
        // Consulta a BBDD y retorno del nombre del archivo con la última entrda
        return $ruta_archivo;
    }
    
    //Invocar la función y vuelcas el contenido del archivo devuelto
    echo file_get_content(cargar_entrada());
    

    or after the include:

    <td>
    <?
    include("cargar_entrada.php");
    echo file_get_content(cargar_entrada());
    ?>
    </td>
    

    The contents of the enrada1.html file within the cell would be displayed correctly in either cell.

    Warnings: * before showing, check the existence of the file

    I have assumed many things, I hope I have made the right decision. If I have guessed the code of carga_pagina.php and how you invoke it within td.

        
    answered by 02.09.2016 / 22:02
    source