Jump to content

[SOLVED] Formatting a value retirved from database


Recommended Posts

hello

I have stored a paragraph in mysql database and when i try to retrive it and sisplay i want to format the paragrapg...

The paragraph is like this

 

1.some text 2.again some text 3.again some text 4.again some text

 

I want my output to be like this

 

1.some text

2.again some text

3.again some text

4.again some text

 

and so on

 

i am able to retrive the praragrapg in a variable like the variable is $paragraph

now i dont no how to cut the line after a number and point(fullstop)

 

Please Help me guys...its urgent

THANKING YOU IN ADVANCE

 

the text are a sequence of step to be followed so the number comes in to effect,

the test input field is a text area,I dont no how to add line break(</br>) while the user write in the text area,I cant ask user to use an html code while writting in a text area,as user are not tech savy.can you please help me out

Can you please give me an example of nl2br(). function

you dont need to use any html tag....

suppose you have saved the value of textarea in a database with column name as paragraph..while writting the paragraph in textarea you have pressed the enter key then whiel displaying the paragraph from database you just need to use the nl2br function like this

echo nl2br($row['paragraph']);

 

//i am assuming that you need to display the paragraphy as it is written in text area..each line in a new line

ur correct u dont need to use any html tags.......

 

when u enter info to the database from a form

 

Each time the user press enter the database updates with specill char, and then use nl2br() to see the date and the line brakes will be shown.......

 

 

 

<?php
if ($_POST['action'] == 'Go Go Go') {
    $text = nl2br($_POST['foo']);
    // now do whatever you want with text, insert it into a database or display it to the user
}
?>
<html>
    <form method="post" action="">
        <textarea name="foo"></textarea>
        <input type="submit" name="action" value="Go Go Go" />
    </form>
</html>

 

related link : http://www.phpfreaks.com/forums/index.php/topic,225590.msg1039786.html#msg1039786

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.