Show html page through index.php > function.php
I explain why the title maybe was going to be a little long and I wanted to simplify it.
I have a page index.php , has a table, where in a tr
,td
(height
and width
already set) has a include ('/funciones/cargar_entrada.php')
, so the contents of this include will be displayed in est tr
,td
.
The function load_input.php , connects to a BBDD and retrieves the last entry (example: input1.html). I have tried to show entrada1.html
testing with;
- includes
echo "< a href='/../entradas/entrada1.html'>< /a>";
<script type="text/javascript"> location.href='/../entradas/entrada1.html'; </script>
So far everything is fine. The case is that it does not show the contents of entrada.1html
in cargar_entrada.php
...
Loading Code_input.php
Servidor server=""; usuario user=""; pass pass=""; BB bbdd="";
Conex connection=mysqli_connect (servidor server,usuario user,pass pass, BB bbdd) or die ("Error 505 NOT FOUND");
Sql sql= " SELECT * from entries ORDER BY id DESC LIMIT 1"; tabla table=mysqli_query (Conex connection, sql sql);
While (fila row=mysqli_fetch_object (tabla table)) {id id=fila row- > id;}
Header ('Location:../ entries / entry'.$ID.'.html');
I know it's very basic but it works for me correctly
Edit: in the end I opted for the following.
In index.php I have created an iframe with src = load_enter.php, and this with the code I have put above, loads the last entry correctly.
Theme fixed, thanks for the help!
1 answers
You say you have tried three different ways to display the contents of a document html
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" including " the contents of the file you indicate. You comment that:
" the function load_entrance.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 html
of the last entry is. Note 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 you have to invoke it somewhere or in the file itself.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());
O well after include:
<td>
<?
include("cargar_entrada.php");
echo file_get_content(cargar_entrada());
?>
</td>
Either way would correctly display the contents of the enrada1.html
file inside the cell.
Warnings: * before displaying, check the existence of the file
I've done a lot of things, I hope I got it right. If I am correct, show us the Page_Load code.php and how you invoke it inside td.