Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

linebreaks with a text field not displaying in results

Engaged ,
Apr 06, 2012 Apr 06, 2012

i have an input field <textarea name="terms" cols="60" rows="5"><?php echo htmlentities($row_Recordset1['terms'], ENT_COMPAT, 'utf-8'); ?></textarea>

the php is

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form4")) {

  $updateSQL = sprintf("UPDATE think_terms SET terms=%s WHERE termsID=%s",

                       GetSQLValueString($_POST['terms'], "text"),

                       GetSQLValueString($_POST['termsID'], "int"));

the results is

<div class="textblack" id="terms_body"><?php echo $row_Recordset1['terms']; ?></div>

it is all coming out as one block

when the text is inputed it is like this

"The standard Lorem Ipsum passage, used since the 1500s

 

"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "

but when display it comes out like

The standard Lorem Ipsum passage, used since the 1500s "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

i tried the "/n" in the <div class="textblack" id="terms_body"><?php echo $row_Recordset1['terms']; ?></div>

but that didnt work

TOPICS
Server side applications
608
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Apr 08, 2012 Apr 08, 2012

<?php echo nl2br($row_Recordset1['terms']); ?>

done it, thanks for the advice

jon

Translate
LEGEND ,
Apr 06, 2012 Apr 06, 2012

>i tried the "/n" in the <div class="textblack" id="terms_body"><?php echo $row_Recordset1['terms']; ?></div>

"/n" ?  Not sure what you mean. When you hit RETURN on the keyboard, a newline character is inserted. Newlines, carriage returns, etc, are all just whitespace. Remember what HTML does to whitespace?  Try using the nl2br function.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 07, 2012 Apr 07, 2012

i take it the nl2br goes in the results

looking at tutorial is says it can go after the echo so by php is

<?php echo $row_Recordset1['terms']; ?>

<?php echo nl2br $row_Recordset1['terms']; ?>

but this is giving syntax errors

where is it meant to go then?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 08, 2012 Apr 08, 2012
LATEST

<?php echo nl2br($row_Recordset1['terms']); ?>

done it, thanks for the advice

jon

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines