another newbie question need help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
php.newbie
Forum Newbie
Posts: 16
Joined: Wed Sep 20, 2006 3:28 am

another newbie question need help!

Post by php.newbie »

Dear All,

I have one question on how to do the following:

I hv a page that submit message and update to my mysql db.
When user type the following msg:
message1
message2
message3

message4

I am able to store in longtext field in my table. However when I display it out to the page, I get the following:
message1message2message3message4

Any ideas how can I print out exactly as what user input?

Any help is grately appreciated.

Thanks,
Richard
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

nl2br() or use a <pre> type tag.
php.newbie
Forum Newbie
Posts: 16
Joined: Wed Sep 20, 2006 3:28 am

Post by php.newbie »

Hi Jcart,

below is my code:

Code: Select all

function prtcontent($id) {
   echo '<table>';
   $query = "SELECT * FROM msgtbl where msg_id='" . $id . "'";
   $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());        					
   if (mysql_num_rows($result) > 0) { 
      while($row  = mysql_fetch_object($result)) { 
             echo '<tr>';
             echo '<td>';
             echo $row->msg_content; 
             echo '</td>';
             echo '</tr>';
               }
          }
Any idea how I can do it?

Thanks,

Richard
php.newbie
Forum Newbie
Posts: 16
Joined: Wed Sep 20, 2006 3:28 am

Post by php.newbie »

hi feyd,

i am using nl2br(). it works great.

Thanks so much for your quick help.

Regards,

Richard
Post Reply