tags:

views:

48

answers:

2
+2  Q: 

PHP and HTML Echo

I want to query a result from a table. The problem I run into is if the text is very long it will not auto-wrap to another line"best way i can think to explain it". It displays the text on one line and will go way off to the side of the page if the text is long. How can I get the text to space correctly. Thanks

here is my code:

<?php
    echo "<div class=\"item_list2\">";
    $get_items = "SELECT * FROM items WHERE category='Art'";
    $result = mysql_query($get_items);
    //loop! loops through the multiple results of the $get_items query
    while($item = mysql_fetch_array($result, MYSQL_ASSOC)){
        echo "<b>" . $item['item'] . "</b><br/>" . $item['email'] . "<br/>";
        echo $item['price'] . "</b><br/>" . $item['category'] . "</b><br/>" . $item['extra'];
        echo "<br/><a href='manage.php?delete=" . $item['id'] . "'><small>[Delete]</small></a><br/><br/>";
    }
    echo "</div>";
 ?>
A: 

Just use CSS to break it.

.container
{
    word-wrap: break-word;
}
Frankie
`\n` doesn't affect how HTML renders. It's interpreted the same as a space.
Matchu
@Matchu, you're right! Read the user wrong. Though he was talking about sorce code.
Frankie
Right, then :) +1
Matchu
@Matchu, thks! ;)
Frankie
ya that worked thanks yall!!!
tim
A: 

maybe you want to add..

nl2br($item['extra']);
Webarto
it still goes outside my container hmm.. thanks for the idea
tim
white-space:pre-wrap; word-wrap: break-word;:)
Webarto