load a div with a php page

Asked

Viewed 1,217 times

1

I’m making a mistake, let’s say, primary kkkk

I have a page made in html updated by php.

My problem is to load the contents of a div.

I have a text. By clicking on this text it loads the content into a div, only this content is a php page, for example teste.php.

The question is.... How to do this?

OBS.:I have a file, below (regras.php)

<?php  switch($_GET["pagina"])
	{		
		case  "adestraBasic":
		$var_conteudo="AdestraBasic.php";
		break;	
		case  "advance":
		$var_conteudo="Advance.php";
		break;	
		
	    default: $var_conteudo="AdestraBasic.php";
		
	}
?>

And on the page I have:

<?php include "regras.php";?>

The div:

<div id="PHP">
    <?php include $var_conteudo; ?>
</div>

Page:

<head>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />

</head>

<body>

<div id="wrapper">
	
	<div id="page">
		<div id="page-bgtop">
			<div id="page-bgbtm">
				<div id="content">
					<div class="post">
						<h2 class="title">curso da iron dog</h2>


<div id="PHP">
   <?php include $var_conteudo; ?>
        </div>

					</div>
				</div>
				<!-- end #content -->
				<div id="sidebar">
					<ul>
					  <li> </li>
						
						<li>
	            <h2>Cursos</h2>
							<ul>
	<li><a href="#">1 Adestramento Basico</a></li>
	<li><a href="#">2 Adestramento Avançado</a></li>
	<li><a href="#">3 Agility</a></li>
	<li><a href="#">4 Cães de Policia</a></li>
	<li><a href="#">5 Figurante</a></li>
								
							</ul>
						</li>
						</ul>
						</li>
					</ul>
              </div>
				<!-- end #sidebar -->
				<div style="clear: both;">&nbsp;</div>
			</div>
		</div>
	</div>
	<!-- end #page -->
</div>

</body>

2 answers

0

You have to pass via GET the name of the page you want the 'rules.php' to receive.

I use the following structure to do this.

Home page:

<?php

//Usuários
$pagina['AdestraBasic'] = "adestra_basic.php";

//Se a variável 'link' for diferente de vazio.
if (isset($_GET["pag"])) 
{
    $link = $_GET["pag"];

    //Se o arquivo da página existir inclui.
    if (file_exists($pagina[$link]))
    {
        include_once $pagina[$link];
    }
    else
    {
        //die (include_once '../includes/pagina_erro.php');
    }
}
//Caso contrário inclui a página 'home'.
else 
{
    //include_once 'home.php';
}

?>

course of Iron dog
  • Courses

    • 1 Basic training
    • 2 Advanced training
    • 3 Agility
    • 4 Police Dogs
    • 5 Extra
 
<!-- end #page -->

Page Adestra Basic:

<?
echo 'Incluiu página adestramento básico!!!';

?>

0

I do the following, get the name of the page by GET, and the original name of the files are the same as the possible Gets. It is very basic to include the page:

$pagina = $_GET['pagina'];
//Faz uma validação do link aqui
...


Chama a página no lugar que você quiser
<?php include $pagina . ".php" ?>

Browser other questions tagged

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