Hey guys and gals,
In my ongoing php experiments I'm trying to build a script and what I would like to do is make a group of links(they will be static) ie....
<a href="index.php">Index</a>
<a href="about.php">About</a>
<a href="etc.php">Etc</a>

But the twist to this is I want it so that they will be embedded into an if/elseif/else grouping that point to additional code.

So the overall layout of the page would be like:
<head>
<included static page with the menu containing the above links>
<divs that "appear" using if statements>
<footer>

If that makes sense.........Now I know there are other ways to do this and probably using AJAX would be easier but I'm stubborn and experimenting.

My thoughts were to make variables and put them in the if statements and forcing the page to refresh....so my thoughts so far would be along the lines of

$index='<a href="index.php">Index</a>';

if ($index=?)
echo '<div></div>
else ($about=?)
echo '<div></div>

Not sure if I'm explaining it thoroughly enough, but I want to know that it is possible and I'm not on glue.

Use switch():

<?php

	$a = 'about'; # replace with $_GET['page']
	switch($a)
	{
		case 'about':
			echo 'about page'; #instead of echo you can include
		break;
		case 'contacts':
			echo 'contact page';
		break;
		default:
			echo 'home page';
		break;
	}

?>

name the page index.php and make these links:

http://your.website/index.php?page=about
http://your.website/index.php?page=contact

If you write something else is not a case switch, then the script will echo the default value. If then you want links like this: http://your.website/about then you need to edit the .htaccess file, search for mod_rewrite to get more information.

commented: Well written +2

I'll give this a shot later today when I get a chance and report back, thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.