Re: help out a noob w/ include & switch?
| From: | Jasper Bryant-Greene | Date: | Tue, 20 Sep 2005 23:15:10 +0000 |
| Subject: | Re: help out a noob w/ include & switch? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-222821@lists.php.net to get a copy of this message | ||
jay thompson wrote:
index.php: <?phpThere is no need to switch in and out of PHP there. Replace all the ?> immediately followed by <?php with nothing.include 'content.php'; //sets the section title echo $title;?> <?phpinclude 'navigate.php'; //sets appropriate navigation menu echo $navigate;?> <?phpecho $content; //loads body text?>
content.php: <?php switch ($cont) {Unless you really have a constant defined called artist1, you probably want to rewrite the case statements as: case 'artist1': [...] case 'artist2,3,4': [...] etc (with the quotes added). If you actually mean 'artist2', 'artist3', and 'artist4' as separate artists, then you'll need to do: case 'artist2': case 'artist3': case 'artist4': separately.case artist1: $title = 'event title'; $content = '<p>some text</p><p>some more text</p><p class="sig">- artist name</p>'; break; case artist2,3,4: [...] break; default: $title = 'event title'; $content = '<p>some text</p><p>some more text</p><p class="sig">- artist name</p>'; break;} ?>
navigate.php: <?php switch ($nav) {as far as I know, you need to actually do these as separate case statements: case 2: case 3: case 4: [...] break;case 1: $navigate = '<ul><li><a href="index.php?nav=1&cont=artist1">Linktitle<br />by artist1</a></li><li><a href="index.php?nav=2&cont=artist2">link title<br />by artist2</a></li><li><a href="">some more stuff</a></li><li><a href="">Contact</a></li></ul>';break; case 2,3,4: [...] break;
-- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/default: $navigate = '<ul><li><a href="index.php?nav=1&cont=artist1">Linktitle<br />by artist1</a></li><li><a href="index.php?nav=2&cont=artist2">link title<br />by artist2</a></li><li><a href="">some more stuff</a></li><li><a href="">Contact</a></li></ul>';break;} ?>