show html page in php

Asked

Viewed 220 times

-4

I am making a code in php, after this code perform its action I would like to show another page in html ex:

echo " <a href= 'main.html' > ";

then the page would appear <main.html>. But I do not know how or if possible... I would like a help or indication of how to do it.

  • And what would that action be? Note that headers cannot be sent if this action is output.

3 answers

1

as already mentioned, headers cannot be sent after the output, so if you do not perform any output, you can use this function to redirect to another page :

header('Location: main.html');

0

The tag <a> HTML is commonly used to build links: <a href="example.com>Exemplo</a>, not to "show" another HTML page.

The simplest solution to solve this problem is by using the function include() of PHP:

<?php
include("minhapagina.html");
?>

This function will fetch the contents of that page and include it on the current page. Using a header() would only redirect the user by adhering to the fact that headers cannot be sent after output.

  • 1

    include("minhapagina.html");

-5

If you want to make the image appear and you are using database... I know how to do.. your echo has to be like this:

$busca_query = mysql_query ("SELECT * FROM tabela WHERE colunanoBD = '$busca'");
while ($dados = mysql_fetch_array($busca_query)) {
echo "<img src='Visual/imagens/$dados[foto]' /></b><br/></a>";

in this case Visual is folder and inside this the image folder and la in the bd in the column you put the image like this > photo.jpg < so this... only the image with extension.

If you want to put one div before the <?php. You can put a style and move with margin left center or right at will by the screen the photo.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.