Re: help out a noob w/ include & switch?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



jay thompson wrote:
index.php:
<?php
        include 'content.php';   //sets the section title
        echo $title;
?>
<?php
        include 'navigate.php';  //sets appropriate navigation menu
        echo $navigate;
?>
<?php
        echo $content;   //loads body text
?>

There is no need to switch in and out of PHP there. Replace all the ?> immediately followed by <?php with nothing.


content.php:
<?php
switch ($cont)
{
        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;
}
?>

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.


navigate.php:
<?php
switch ($nav)
{
        case 1:
                $navigate = '<ul><li><a href="index.php?nav=1&amp;cont=artist1">Link
title<br />by artist1</a></li><li><a
href="index.php?nav=2&amp;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;

as far as I know, you need to actually do these as separate case statements:

case 2:
case 3:
case 4:
	[...]
break;

        default:
                $navigate = '<ul><li><a href="index.php?nav=1&amp;cont=artist1">Link
title<br />by artist1</a></li><li><a
href="index.php?nav=2&amp;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;
}
?>


--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux