portabletelly Posted October 17, 2009 Share Posted October 17, 2009 Ok so Im not to sure if this is the right thread to post in but here is my catch 22 issue. I have a test web page www.aandstech.com.au/test.php Test.php pulls its content from a my sql table. This works fine. When I pull down the info without <pre>code to retrieve data from mysql database</pre> tags I loose all my formating ie carraige returns. However the justify works fine. When I use my <pre> tages to retrieve data from mysql database the carrige returns are fine however the text goes right accross the entire page and not within its div. I have made some headway into resolving this issue by using <pre width="80"></pre> However this fix looks fine in firefox 3 but has absoultley no effect in ie6 through to 8.0. Anyway heres a snippet of my code any help would be greatley appreciated. [color=red]<div class="body"> <p> <?php $db =mysql_connect("localhost", "******", "*******"); mysql_select_db("*****_*****",$db); $result = mysql_query("SELECT * FROM ***** WHERE id = 1",$db); while($myrow = mysql_fetch_array($result)) { echo "<pre width='80'>"; echo "<font face='Lucida Sans Unicode' size=2>"; echo $myrow["data"]; echo "</font>"; echo "</pre>"; } ?> </p> </div>[/color] Another thing is that Im using css and any text pulled from a table doesn't use the css thats why I had to put the fonts in. Quote Link to comment https://forums.phpfreaks.com/topic/178018-formating-when-pulling-data-from-a-mysql-database/ Share on other sites More sharing options...
cags Posted October 17, 2009 Share Posted October 17, 2009 Check out the nl2br function. It converts newline characters to <br/> tags so that your line breaks will appear in your text without using the <pre> tags. Quote Link to comment https://forums.phpfreaks.com/topic/178018-formating-when-pulling-data-from-a-mysql-database/#findComment-938610 Share on other sites More sharing options...
portabletelly Posted October 17, 2009 Author Share Posted October 17, 2009 I just added the following while($myrow = mysql_fetch_array($result)) { echo "<pre width='80'>"; echo "<font face='Lucida Sans Unicode' size=2>"; echo nl2br($myrow["data"]); echo "</font>"; echo "</pre>"; } It appears that the carriage returns just got more space it didn't effect the width in anyway. Strange thing is this page looks fine in firefox but no IE. Would this be the correct syntax echo nl2br($myrow["data"]); Quote Link to comment https://forums.phpfreaks.com/topic/178018-formating-when-pulling-data-from-a-mysql-database/#findComment-938616 Share on other sites More sharing options...
portabletelly Posted October 17, 2009 Author Share Posted October 17, 2009 ingnore that last post commenting out pre fixed the issue while($myrow = mysql_fetch_array($result)) { //echo "<pre width='80'>"; echo "<font face='Lucida Sans Unicode' size=2>"; echo nl2br($myrow["data"]); echo "</font>"; //echo "</pre>"; } Quote Link to comment https://forums.phpfreaks.com/topic/178018-formating-when-pulling-data-from-a-mysql-database/#findComment-938618 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.