Page 1 of 1

format posted data

Posted: Tue May 26, 2009 2:25 pm
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?

Re: format posted data

Posted: Tue May 26, 2009 2:55 pm
by requinix
Use it on the data that needs it.

Do you not understand PHP?

Re: format posted data

Posted: Tue May 26, 2009 3:01 pm
by rugbyfreak
i tried before the $row but it didnn't worked and then before ["commentaire"] and didn't worked too.

Re: format posted data

Posted: Tue May 26, 2009 4:45 pm
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?

Re: format posted data

Posted: Tue May 26, 2009 5:01 pm
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/>";
/* .......... */