Jump to content

[SOLVED] php navagation


lennon123

Recommended Posts

hi guys,

this is probably a very basic question, hopefully this will be a doddle to answer.

Im fairly new to php, I have a menu set up and when the user clicks on one of the links it parses a value to the variable $page. What I want php to do is display a text file, dynamically, based on the value of $page.

i.e

if $=home then dynamically load in home.txt into a div tag and so on.

Any one help?

cheers

 

Link to comment
https://forums.phpfreaks.com/topic/101360-solved-php-navagation/
Share on other sites

I would use a $_GET and a switch.

<html>
<body>
<a href="index.php?page=home">Home</a>
<a href="index.php?page=about">About</a>
<a href="index.php?page=contact">Contact</a>
<?php
$p = $_GET['page'];
switch ($p)
{
case "home":
	include "home.txt";
	break;
case "about":
	include "about.txt";
	break;
case "contact":
	include "contact.txt";
	break;
default:
	include "error.txt";
	break;
}
?>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.