Indentation and line breaking in sql data for html

Asked

Viewed 430 times

1

In short, I created a table with type text in sql so that the user can save some content. However when pulling it back into HTML the formatting is lost.

To remedy this I thought of using the tag < pre >, but the tag < pre > fills my layout of bugs, as I recoil too much only in the first paragraph, and does not break the line if the text is too large, it expands the width of the page. Have some own way to maintain this text formatting?

Ps. the code in question must return several records, so there is no way to predict where the line break will appear. The image below was just a random record for testing

Texto formatado na tag <PRE>

Below is the backend code used:

entree:

$query = $conect -> query( 'INSERT INTO textos (texto) VALUES({$_POST['texto']}')');

exit:

$query = $conect -> query("SELECT * FROM textos");

in html / php:

while ($temp = $query->fetch_assoc() ) { ?>
     <div><pre>
          <?PHP echo $temp['texto']; ?>
      </pre></div>
<?php}  ?>
  • What backend language is using?

  • Backend am using PHP.

  • Post your code php so we can help.

  • My php has nothing else... A textarea being posted via a form.. and being retrieved via a select. I will post.

  • The question is not what has yours php and yes in order to help you, we have to see what has been done.

  • Code posted.

  • just use the <p></p>

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.