473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

new lines in form

well, it is time for some fine tuning of my application, after adding
that banner script for which I needed percentage solution, I would like
to fix my forum scripts...
when someone write some text in form's textarea and then
enter
new line (btw, is that \r or \n or combination?) I'm not "getting" that
new line but space. what can I do to "recieve" and store (in mysql db)
text with newlines instead of spaces. and, even better, to replace that
newline with </p>\n<p>...

tnx again

--
Ja NE
http://fotozine.org/?omen=janimir
--
Oct 25 '05 #1
3 1611
Ja NE <hi****@mail.zz> wrote:

....ok.
have it ;-))

$tekst = preg_replace("/\r\n/", "\n", $tekst);
$tekst = preg_replace("/\n/", "</p>\n<p>", $tekst);

thank you "manual" ;-)
well, it is time for some fine tuning of my application, after adding
that banner script for which I needed percentage solution, I would like
to fix my forum scripts...
when someone write some text in form's textarea and then
enter
new line (btw, is that \r or \n or combination?) I'm not "getting" that
new line but space. what can I do to "recieve" and store (in mysql db)
text with newlines instead of spaces. and, even better, to replace that
newline with </p>\n<p>...

tnx again

--
Ja NE
http://fotozine.org/?omen=janimir
--
Oct 25 '05 #2
IWT
Ja NE wrote:
when someone write some text in form's textarea and then
enter
new line (btw, is that \r or \n or combination?) I'm not "getting" that
new line but space. what can I do to "recieve" and store (in mysql db)
text with newlines instead of spaces. and, even better, to replace that
newline with </p>\n<p>...

I've just done something very similar:

$description=$_POST['textarea'];

$description = strip_tags($description); // Remove any HTML tags
$description = "<p>".$description; // Add <p> to start
$description = str_replace("\r\n","</p><p>", $description); // Replace
new lines with paragraph

if(substr($description,-3)=="<p>") // Remove last <p> from description
$description = substr($description,0,-3);

Oct 25 '05 #3
Ja NE wrote:
well, it is time for some fine tuning of my application, after adding
that banner script for which I needed percentage solution, I would like
to fix my forum scripts...
when someone write some text in form's textarea and then
enter
new line (btw, is that \r or \n or combination?) I'm not "getting" that
new line but space. what can I do to "recieve" and store (in mysql db)
text with newlines instead of spaces. and, even better, to replace that
newline with </p>\n<p>...

tnx again


Jane,

That's the way HTML works - if you look at the page source and you'll
see the newlines in there. But processing the HTML gets rid of them.

You need to use something like PHP's nl2br() function to convert newline
characters to html breaks.

It can get very confusing when a newline "isn't" a newline!
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 25 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Katrin Limp?ck | last post by:
Hi all, is there a possiblity to count the lines in a sub report? Background: I have a form, where to put data, in this form there is a fixed place, where I put the sub report. I know, that I...
3
by: Rolf | last post by:
I have a form with about 15 to 20 lines. Their names are LineXXX. What code can I put in the click event of a button to delete all the lines? Thanks! Rolf
5
by: Brian | last post by:
Hello all.. Am working on an Air Hockey game... have an table loaded into a picture box. The borders of the table are slightly slanted. Am using hit testing lines with GDI+ to manipulate the...
2
by: George | last post by:
Dear colleagues, I refer to your help with specific graphic problem. It is necessary to create a viewfinder in graphic application. It seems that the algorithm is simple: just draw lines in...
23
by: Paul Mars | last post by:
I need to limit multiline textbox to 3 lines of text and if there are less then 3 lines when leaving, add empty line holders. How can I do this?? Thanks, paul
3
by: Mark | last post by:
Hello all - I'm creating an application that uses a datagridview control. My development environment is an HP Laptop with a NVIDIA Geforce 4 440 Go 64M. While using this object, a queer...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
4
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I've windows form, in this form i've a panel. I want to draw lines inside the panel using the panel coordinates( meaing that the left upper corner of the panel is 0,0), how can i do it? ...
7
by: Gustaf | last post by:
Hi all, Just for fun, I'm working on a script to count the number of lines in source files. Some lines are auto-generated (by the IDE) and shouldn't be counted. The auto-generated part of files...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.