www.webdeveloper.com
Results 1 to 7 of 7

Thread: Pad out HTML using PHP

  1. #1
    Join Date
    Nov 2002
    Location
    Scotland
    Posts
    550

    Pad out HTML using PHP

    Hello,

    I am currently extracting my XHTML from a couple of fields in a database to make up the main content of the pages.

    However when I echo it out all the <div>'s get bunched up together in the source code, and I'm sure this is why it gives me layout errors in Safari, and nothing else.

    Is there any way to 'pad out' the spacing between parts of the HTML.

    I'd tried using the '\n\n' and it worked on something else, but not this one sadly.
    PHP Code:
    echo '<div class="centrewide">';
    echo 
    '<img src="' $main_image '" alt="' $title '" />';

    echo 
    '<div class="left_content2">';
    echo 
    $left_content;
    echo 
    '</div>';
    echo 
    '<font color="#fff">';
    echo 
    '\n\n';
    echo 
    '</font>';

    echo 
    '<div class="centre_content2">';
    echo 
    $centre_content;
    echo 
    '</div>';
    echo 
    '<font color="#fff">';
    echo 
    '\n\n';
    echo 
    '</font>';

    echo 
    '<div class="right_content2"><img src="../img/answers_questions.jpg" width="154" height="741" /></div>'
    The variables like $centre_content are XHTML taken from the SQL database.

    I'm sure I've seen an easy way to 'pad' out the coding, but just can't seem to do it.

    Any solutions would be most helpful.


    Thank you!

  2. #2
    Join Date
    Nov 2002
    Location
    Scotland
    Posts
    550
    I'm not even too sure if that's the problem.

    I've XHTML/CSS-validated it, but nothing major has turned up. Just Safari I guess.

  3. #3
    Join Date
    Aug 2006
    Posts
    255
    You need double quotes around your "\n\n".

    Using single quotes will echo precisely what you type (in this case, literally putting \n\n in to your HTML source code). Using double quotes will interpret the special characters (turning \n\n in to new lines, for example).

  4. #4
    Join Date
    Nov 2002
    Location
    Scotland
    Posts
    550
    aaaah. Thanks, of course. Will try that.


    Thanks.

  5. #5
    Join Date
    Nov 2002
    Location
    Scotland
    Posts
    550
    Hmm, I seem to have resolved it, slightly.

    Problem seems to be the picture stored in the .centrewide class.

  6. #6
    Join Date
    Nov 2002
    Location
    Scotland
    Posts
    550
    Yup, it was that.

    Just added a div to clear both and it was sorted

    Thanks for the help and apologies for the slightly meaningless posts above.

  7. #7
    Join Date
    Aug 2006
    Posts
    255
    No worries. Glad you got it fixed.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles