The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

Wrap a DIV around PHP code?

  • # December 10, 2008 at 1:43 pm

    First of I wanna say that I’m not good in describing things especially in english so bare with me :oops:

    So, I’m really lost here, I have this major problem and I’m really confused.. I’m making a guestbook in PHP and it works just fine, but what I REALLY would love to do is to have the post’s wrapped inside of a css div.. And that’s a big problem, because I can’t write like this:

    < ?php

    echo “Hey people”;


    If I just wrap a DIV outside of ALL the php code, then it will only come in one div.. I want it like when users submit there message in the form, there message will be stored with the rest of the comments, but in there own div’s..

    I dont know how to explain this, but it’s only some of the php code, the actual outcome I want to wrap in a DIV.. And theres no way I can you css directly inside of php??


    Hope somebody understand’s me, and can help me out here..

    Thank’s so far

    # December 10, 2008 at 4:53 pm

    Problem solved, you can close this thread. :D

    # January 22, 2009 at 7:27 pm


    I need the answer to this question too!

    @BrianZet – How did you figure this one out?

    # January 22, 2009 at 7:35 pm

    Thur, I’m not sure if your problem is exactly the same as the original topic… but you can echo divs just like any other element you might echo out:

    echo "<div>";


    echo "</div>";

    # January 23, 2009 at 7:26 pm

    echo "<div>" . $elevData[1] . "</div>";

    surely wouldnt that put the data in a div?

    # January 23, 2009 at 7:33 pm

    You don’t need to echo every line individually…

    < ?php echo '
    Hey people




    < ?php ?>

    Hey people

    < ? ?>

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed