I want to insert each line of the user <br/> when I get data in my table.
After researching the net, I came across the nl2br function to allow this.
The insertion of "<br/>" is made correctly but when I update my textarea, I find myself with several "<br/>" stuck in a row.
I tried nl2br (htmlentities ($var)) but nothing fits in my desk.
Inserting data into my table:
PHP Code:
$ field_form1 = addslashes($_POST['field1']);
$ field_form2 = addslashes($_POST['field2']);
$ field_form3 = addslashes($_POST['field3']);
$ field_form4 = addslashes($_POST['field4']);
$ field_form1 = explode("\n",$field_form1);
$ field_form2 = explode("\n",$field_form2);
$ field_form3 = explode("\n",$field_form3);
$ field_form4 = explode("\n",$field_form4);
....
Displays data in the textarea :
PHP Code:
echo '<textarea name="field'.$i.'" rows="10">';
$sql_textarea = mysql_query ("select id_description, text $i"."_description from description where theme_description = '$theme' and nb_parts_description = '$nb");
while ($data = mysql_fetch_array ($sql_textarea)) {
$content = nl2br ($data["text $i"."_description"]);
echo htmlentities ($content);
}
echo "</textarea>";
Bookmarks