i hava a col in database called "features" and its type "text".

some where in my website page i have a textarea. where user can list features. here is a ex:
lets say below is a text area and user is entering features. at end of line is enter

<textarea type="text" name="fea" > 
    -----------------------------------
    color is red.
    size is large.
    random features1
    random features2
    etc...
    -----------------------------------
</textarea>

now calling name='fea' and storeing value in database 'features'. here is how 'features' look like in database:

features: color is red
          size is large 
          random features1
          random features2

now i am getting the value of features from database

$item_query = mysql_query("SELECT * FROM item"); 
$row = mysql_fetch_assoc($item_query)
$features_db = $row['features'];

here is the problem is. when i echo'$features_db'; it doesnt prints the enters. so for ex it print this:

 color is red  size is large  random features1 random features2

but i want to print in a nice list like this

  • color is red
  • size is large
  • random features1
    ...
Member Avatar for LastMitch

@hwoarang69

here is the problem is. when i echo'$features_db'; it doesnt prints the enters. so for ex it print this:

Instead of this

echo'$features_db';

Try to add this:

echo "$features_db\n";

it prints and puts enter at end of line.

color is red  size is large  random features1 random features2 \n

how it is stored in mysql, Is it in one column one row, or all features are in separte record?

If it is strored using textarea (with user manually breking line in textarea) then following trick may work, no need of \n

echo nl2br($features_db);

awesome got it to working. so nl2br takes \n from textarea?

that function if finds new line in string, it renders it to html <br> tag.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.