wmguk Posted July 8, 2008 Share Posted July 8, 2008 Hey guys, In my db I have one field which is set as 'text'. When i write infomation in the field it looks ok in the input box: Super Relief creates the look of natural stone but in a ceramic tile. Tile Suitability: Kitchen and Bathroom Tile Material: Ceramic Tile Finish: Matt Price Per: Tile however when its displayed all the formatting is lost and its displayed as: Super Relief creates the look of natural stone but in a ceramic tile. Tile Suitability: Kitchen and Bathroom Tile Material: Ceramic Tile Finish: Matt Price Per: Tile Any ideas how i can get it to keep the formatting with <br> etc - the colour and size/font etc is all done via a stylesheet Its only on the information pulled out of the db, - but if i edit it, then in the input box the formatting and line breaks etc are all there too... seems odd Link to comment https://forums.phpfreaks.com/topic/113742-solved-losing-formatting-on-pages-when-info-is-pulled-out-of-db/ Share on other sites More sharing options...
Andy-H Posted July 8, 2008 Share Posted July 8, 2008 Can you show the code where the info is outputted please? Link to comment https://forums.phpfreaks.com/topic/113742-solved-losing-formatting-on-pages-when-info-is-pulled-out-of-db/#findComment-584504 Share on other sites More sharing options...
wmguk Posted July 8, 2008 Author Share Posted July 8, 2008 Can you show the code where the info is outputted please? i can - its simply <?PHP echo ucfirst($row['info']);?> also i notice if i actually type in the html it will display it correctly, i.e. Trialation Tile creates the look of natural stone but in a ceramic tile.<br><br> Tile Suitability: Kitchen and Bathroom<br> Tile Material: Ceramic<br> Tile Finish: Matt shows: Trialation Tile creates the look of natural stone but in a ceramic tile. Tile Suitability: Kitchen and Bathroom Tile Material: Ceramic Tile Finish: Matt Link to comment https://forums.phpfreaks.com/topic/113742-solved-losing-formatting-on-pages-when-info-is-pulled-out-of-db/#findComment-584508 Share on other sites More sharing options...
Andy-H Posted July 8, 2008 Share Posted July 8, 2008 I used to have a text based mafia site with a messaging system, it worked fine for me in a text field like this: <tr><td align="center" class="sub" colspan="2">Message</td></tr> <tr><td align="center" class="tbl" colspan="2"> <textarea name="msg" class="submit" cols="35" rows="5"> <?php if ($rep){ print (" [b]On: ".$on." ".$from." Wrote:[/b] ".$mssg.""); } ?> </textarea> </tr></tr> That was for sending/replying to a message. <?php $tit = $_GET['read']; if ($tit == $id){ ?> <tr> <td align="center" class="tbl" colspan="8"><? print replace($msg); ?></td> </tr> <?php mysql_query("UPDATE `inbox` SET `read` = '1' WHERE `playername` = '$player' AND `id` = '$tit' LIMIT 1")or die(mysql_error()); } }} ?> That was where I displayed the message, the formatting worked fine for me like that. Link to comment https://forums.phpfreaks.com/topic/113742-solved-losing-formatting-on-pages-when-info-is-pulled-out-of-db/#findComment-584517 Share on other sites More sharing options...
thatsgreat2345 Posted July 8, 2008 Share Posted July 8, 2008 Use <pre> </pre> around the text you want to display. Link to comment https://forums.phpfreaks.com/topic/113742-solved-losing-formatting-on-pages-when-info-is-pulled-out-of-db/#findComment-584522 Share on other sites More sharing options...
wmguk Posted July 8, 2008 Author Share Posted July 8, 2008 hey, your code was hidden on this page but i viewed the source and found the <pre></pre> so tried that, and now i've added the class to it, its sorted, thanks for your help Link to comment https://forums.phpfreaks.com/topic/113742-solved-losing-formatting-on-pages-when-info-is-pulled-out-of-db/#findComment-584531 Share on other sites More sharing options...
Andy-H Posted July 8, 2008 Share Posted July 8, 2008 Add a set style in your stylesheet for pre tags like: pre { code } Link to comment https://forums.phpfreaks.com/topic/113742-solved-losing-formatting-on-pages-when-info-is-pulled-out-of-db/#findComment-584536 Share on other sites More sharing options...
wmguk Posted July 8, 2008 Author Share Posted July 8, 2008 yes, sorry, all sorted now thank you Link to comment https://forums.phpfreaks.com/topic/113742-solved-losing-formatting-on-pages-when-info-is-pulled-out-of-db/#findComment-584782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.