Page 1 of 1

another newbie question need help!

Posted: Sat Oct 28, 2006 8:40 pm
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

Posted: Sat Oct 28, 2006 8:44 pm
by feyd
nl2br() or use a <pre> type tag.

Posted: Sat Oct 28, 2006 8:50 pm
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

Posted: Sat Oct 28, 2006 8:54 pm
by php.newbie
hi feyd,

i am using nl2br(). it works great.

Thanks so much for your quick help.

Regards,

Richard