Page 1 of 1

newb - basic layout with menu to fill text area

Posted: Wed Nov 26, 2008 9:51 am
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

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

Posted: Wed Nov 26, 2008 12:50 pm
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! :)

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

Posted: Wed Nov 26, 2008 12:53 pm
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.