Forums

PHP: IF statement around HTML (5 posts)

  1. Michiel
    Member
    Posted 7 years ago #

    Hi! I am not an PHP expert but managed to get the calendar displayed only when the user is in category 1 or the frontpage by using the following:
    <li id="calendar">
    <?php if (in_category(1)) get_calendar(); ?>

  2. I would like to know how I can change this to the following construction:
    IF in category 1
    LI
    command
    /LI
    END IF
    Thanks a lot for you help!!!

  • Beel
    Member
    Posted 7 years ago #

    use
    echo "LI";
    command;
    echo "/LI";

  • Michiel
    Member
    Posted 7 years ago #

    Hi Beel! Thanks a lot (again!). One question still... how do I handle the "" in PHP? I have now:
    <?php if (in_category(1))
    echo "<li id=""calendar"">"; ?>
    but it does not like the ""... I have been trying to find a solution on php.net but did not succeed yet... THANKS!

  • Michiel
    Member
    Posted 7 years ago #

    Hi Beel! ok! I am not sure yet which key it is as I am working from a finnish keyboard but will check on Monday at work.
    I now tried this one (removed the "<? ?>" perhaps that works better to post it... php if (in_category(1)) echo "<li id=""calendar"">";
    I still get the error : Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home2/.../public_html/blog/index.php on line 112

  • Michiel
    Member
    Posted 7 years ago #

    Beel, nevermind the above to posts.... IT WORKS :-) Thanks!!!

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags

    No tags yet.