format posted data

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
rugbyfreak
Forum Newbie
Posts: 10
Joined: Sat May 16, 2009 12:41 pm

format posted data

Post by rugbyfreak »

Code: Select all

$result = mysql_query("SELECT * FROM commentaire");
 
while ($row = mysql_fetch_array($result))
  {
  echo $row["datetime"];
  echo "<br/>";
  echo $row ["commentaire"];
  echo "<br /><hr/>";
  }
where do i have to put this "n2lbr" to have breaks where my user pressed an enter?
Last edited by Benjamin on Tue May 26, 2009 4:25 pm, edited 1 time in total.
Reason: Changed code type from text to php.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: format posted data

Post by requinix »

Use it on the data that needs it.

Do you not understand PHP?
rugbyfreak
Forum Newbie
Posts: 10
Joined: Sat May 16, 2009 12:41 pm

Re: format posted data

Post by rugbyfreak »

i tried before the $row but it didnn't worked and then before ["commentaire"] and didn't worked too.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: format posted data

Post by requinix »

rugbyfreak wrote:i tried before the $row but it didnn't worked and then before ["commentaire"] and didn't worked too.
What was the code you tried?
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: format posted data

Post by Zoxive »

As long as the user had line breaks. (\n) It should work around the $row['blahblah']

Code: Select all

<?php
/* .......... */
echo nl2br($row["datetime"]);
echo "<br/>";
echo nl2br($row ["commentaire"]);
echo "<br /><hr/>";
/* .......... */
 
Post Reply