Hi I use a form to submit my data(a discription in this case) via php. Is there a way I can keep for formatting, namely the paragraphs? when i print them back out of my database its taken the carriage returns out.
thanks for your time,
Thanks for the reply. I've tried it but it doesnt do the job.
basicaly in the text area, when i press return for a newline can i somehow store the carriage return? i dont really want to be putting in <BR> or /n while im trying out a product description.
i bet they're still there
html considers carriage returns as white space
You shouldn't change the way you store the data in the database, but apply the nl2br function when you show the text.
The reason you should do this when displaying instead of when saving is that every time the user would save the description more <br/>'s would be added on each save (when using the "change before inserting" approach)
lol i did try that but must have been using it in another way
TY just the trick
apparently, there is a nl2br (new line to break) function
been trying to do something like this but it doesnt work
$row = ereg_replace(" ","/n",$row);
// connect to db
// assumption: some_table is empty (0 rows)
/* assumption. $_POST['description'] = "This is a\
$desc = mysql_real_escape_string($_POST['description']);
$sql = "INSERT INTO some_table(description) VALUES($desc)";
$sql = "SELECT * FROM some_table";
$row = mysql_fetch_assoc(mysql_query($sql));
This is a<br />
well does this mean I can do some sort of string replace before i show the product? and what code am i looking for carriage return?