newb - basic layout with menu to fill text area

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gunfodder
Forum Newbie
Posts: 3
Joined: Thu Sep 27, 2007 8:19 pm

newb - basic layout with menu to fill text area

Post by gunfodder »

I have a menu.php, index.php, and testvars.php
the menu is using <a href='index.php?txtfld=$maintext'>Home</a>
the testvars.php <?php $maintext='stuff to say on first page'; ?>
the index.php is <?
<?php require('testvars.php');
$varname=$_GET['txtfld'];
$whatyasee=$varname;
?>
<?php print($whatyasee); ?>

In all the above mess I am trying to set one index page and one menu page and and one variable page that I can change text so that when a person clicks a link they are essentially at the same page, but with different information.

What function or code should I be looking toward to accomplish this technique?

Thank you
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: newb - basic layout with menu to fill text area

Post by JAB Creations »

What I think you want to do is something like this...

Code: Select all

<div><a href="index.php?page=1">page 1</a></div><div><a href="index.php?page=contact">contact</a></div><div><a href="index.php?page=stuff">page 3</a></div>
To make that work you would simply use $_GET to determine which page was requested to then determine what content to display...

Code: Select all

<?php
if ($_GET['page'] == "1") {display_content("1");}// call a function to display content
else if ($_GET['page'] == "contact") {display_content("contact");}
else if ($_GET['page'] == "stuff") {display_content_stuff();}//Or make individual functions per page as so
 
function display_content($requested_page)
{
 if ($requested_page == "1") {echo 'you requested page 1';}
 else if ($requested_page == "contact") {echo 'contact page, use a form and don\'t post actual email address unless you want spam!';}
}
 
display_content_stuff()
{
//This is a static way of displaying content without using a parameter
echo 'so you want to see stuff eh?';
}
?>
Hope this helps! :)
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: newb - basic layout with menu to fill text area

Post by JAB Creations »

The forum isn't showing my escaped quotes so if you echo 'you must escape single quotes between opening and closing single quote';...same with double quotes.
Post Reply