Jump to content

[SOLVED] Creating "readable' VARCHAR


NewbieBryan

Recommended Posts

Hi All,

 

I have created an application that collects information for various people (form submissions) and writes this back to a MySQL db (VARCHAR)

 

All works well but when I read back the "Comments" table then the string is improperly formated, well rather it doesn't remember the formatting.

 

So - for example: If someone typed in:

 

Hello all,

I have the following

A dog,

A Cat

 

when I write it to screen it displays

 

Hello all,I have the following A dog,A Cat

 

Is there a manner in which I can keep the formatting (spaces, etc):

 

Tx

Link to comment
Share on other sites

Great, tx Ignace,

 

Looking at the raw data in the dB I see that it is displayed naturally (ie: as it was written) but I assume the /n and whatnot are "hidden" when viewing the PhpMyadmin but this is a great start.

 

Next bit;

 

When I pull the data to display I am using the following

 

echo "<tr>";

 

  echo "<td>" . $row['Comment']             . "</td>";

  echo "<td>" . $row['Author'] . "</td>";

 

 

  echo "</tr>";

 

That works great as is; but

 

Can I now be "clever" and insert nl2br in there somewhere?

 

Maybe:

 

. $row[nl2br('Comment')]

Link to comment
Share on other sites

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.