Jump to content

[SOLVED] Losing formatting on pages when info is pulled out of DB


Recommended Posts

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

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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.