elite311 Posted January 7, 2012 Share Posted January 7, 2012 Hi, I'm trying to build my own news system with PHP and SQL, I have everything working but I'm completely stuck on one element. I have created a DIV container for the SQL output to show in however the SQL output just goes right through the DIV and doesn't wrap the output. Here is my code: <?php include('config.php'); $db = new Database($db_host, $db_username, $db_password, $db_database, $db_table_prefix); $db -> connect(); $result = $db->fetch_all_array("SELECT * FROM news ORDER BY id ASC"); ?> <div id="news"> <?php foreach($result as $option) { ?> <div class="news-heading"><?php echo $option['newshesding'];?></div> <div class="news-text"><?php echo $option['newstext'];?></div> <?php } ?> </div> I have used this code to make it wrap and it does what I want by wraping after 10 characters. <div class="news-text"><?php echo wordwrap($option['newstext'], 100, "\n", true);?></div> However I'm trying to figure out how to do this with the DIV itself, because on a smaller device like my iPhone using the above code doesn't diplay properly as the text runs right to the edge of the screen. My CSS looks like this: #news .news-text{ padding-bottom:15px; white-space:pre; padding-left:5px; padding-top:5px; } If anyone can help I'd appreciate it, thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.