Forum Moderators: coopster
in any case, if you go to this link, <snip> , you'll see what i'm trying to set up. hopefully on your browser it'll show up fine (there's a lot of heavy graphics and CSS positioning and i haven't tested the design on multiple browsers), so if it doesn't and looks like a big mess, i apologize. you'll see the template, which includes mostly graphics on the uppder half and the "dynamic" content part on the lower half (which is just repeating text right now), separated by the thin horizontal menu. so it all shows up, which is a good thing... it's loading the template and content.
i've tried to set it up so that when you acess "test.php" or "test.php?section=home", you'll get the "main test content" repeating text, which is via the file test.txt; when you access "test.php?section=content1" you get "content 1" repeating via content1.txt; and for "test.php?section=content2" you get "content 2" repeating via content2.txt. if you look in the upper right corner, you'll see a small menu. i've set the "CONTACT" link to for content1, the "GUESTBOOK" link for content2, and "PLACES" for home.
my problem is that most of the time, the wrong content loads. in fact, it's loading content 1 almost all of the time. when i tried the page out for the very first time, it seemed fine because it loaded the "main test content". when i tried content 1, it loaded content 1. but when i tried content 2, it stayed on content 1, and it seems to be staying put. i'm guessing once $section is set as content1 the browser or program seems to remember that and keeps that value despite all the refreshing and switching links, but i really don't know. i have no idea how to fix this? and are people seeing the same problem?
here's what i have in the test.php :
<?php
include_once('bTemplate.php');
$tpl = new bTemplate();
if ($section == 'content1') {
$title = 'content 1';
$tpl->set('title', $title);
$tpl->set('content', $tpl->fetch('content1.txt'));
}
else if ($section == 'content2') {
$title = 'content 2';
$tpl->set('title', $title);
$tpl->set('content', $tpl->fetch('content2.txt'));
}
else if ($section == 'home') {
$title = 'main content';
$tpl->set('title', $title);
$tpl->set('content', $tpl->fetch('test.txt'));
}
else {
$title = 'main content';
$tpl->set('title', $title);
$tpl->set('content', $tpl->fetch('test.txt'));
}
echo $tpl->fetch('test.tmp');
?>
all help is MUCHO APPRECIATED! i'm guessing it's something really simple for anyone who is familiar with PHP or knows what they're doing with web programming... but as for me, i'm just clueless.
hope all is doing well...
[edited by: jatar_k at 5:30 pm (utc) on June 15, 2003]
[edited by: ginnymin at 5:52 pm (utc) on June 15, 2003]
You just got hit by a real GOTCHA! ;)
if ($section = 'content1') {
Should be
if ($section == 'content1') {
== means 'equal to' or 'is same as'
and
= means 'equals'
With me? Each time you run that script it's saying 'content IS "content1"'......
Take a look at this:
[php.net...]
Nick
[edited by: Nick_W at 5:36 pm (utc) on June 15, 2003]
The first thing that comes to mind is change all of your = to == in your if statements.
= is the assignment operator, which means you are assigning a new value to $section and since $section = 'content1' is the first one it is the one loading.
== is the comparison operator which is what you want to do.
<added>Nick beat me, darn ;)
I missed it the first time too Nick, your question tipped me off ;)