Web Hosting Talk







View Full Version : Line Spacing with MySQL Information


Ebart
08-29-2002, 06:21 AM
When i insert a multi line variable into mysql i.e

"Title: New
Band: After
Shop: Pro

...... Information Here"

I dont wanna have to put <br> in for each time i want it to add a line space in.

When i display the mysql information inside a form textarea it works fine, but if i display it in a regular table it wont include the spaces and it would turn out like this..

"Title: New Band: After Shop: Pro ...... Information Here"

What functions do i need to put in when adding and querying from the database. Ive tried trim(), addslashes() and stripslashes() which had no effect.

shaunewing
08-29-2002, 06:28 AM
What about using 'nl2br'?

Basically this function converts all newlines to <br>

For more information including usage you can look at http://www.php.net/manual/en/function.nl2br.php

Hope that's what you were after!

--Shaun

Rich2k
08-29-2002, 06:39 AM
Originally posted by shaunewing
What about using 'nl2br'?

Basically this function converts all newlines to <br>

--Shaun

Of course new versions converts newlines to <br /> ;)

shaunewing
08-29-2002, 06:46 AM
Originally posted by Rich2k


Of course new versions converts newlines to <br /> ;)

Yes, of course - I actually just noticed that when looking at the page :)

--Shaun (who is proud to announce that his new personal site is XHTML 1.0 compliant according to the W3C validator :D).

Rich2k
08-29-2002, 08:20 AM
Originally posted by shaunewing

-- who is proud to announce that his new personal site is XHTML 1.0 compliant according to the W3C validator.

Wow someone with XHTML 1.0 compliance... now that's rare!

Have you read about XHTML 2.0... basically will break all existing sites coded in XHTML 1.0 and below!

http://news.com.com/2100-1023-949492.html

Of primary concern to some Web developers is the W3C's warning that XHTML 2.0 will not be "backward compatible" with HTML 4.0 and XHTML 1.0. That alert has raised concern that billions of existing Web pages risk obsolescence unless they are translated to the new Web language.

shaunewing
08-29-2002, 09:33 AM
Originally posted by Rich2k

Wow someone with XHTML 1.0 compliance... now that's rare!

I was surprised, I had to design a personal site for myself (I took it down in January) and thought I'd do it in XHTML as my first XHTML site.

The first run through the validator had 1 error, about a table height tag which I then moved to the CSS. I then ran it through again and voila! :D

Have you read about XHTML 2.0... basically will break all existing sites coded in XHTML 1.0 and below!

Hmm, thanks for the link. Made for an interesting read. Now I wonder if I should start converting my sites over to 1.0/1.1 or wait for 2.0 :)

--Shaun

jtrovato
08-30-2002, 09:59 AM
When displaying the contents of I am assuming a text field in the MySQL database.

When I print I use something like this and then format the text the way I want witht he <font></font>

<pre><font size=3> <? echo $row->textfield; ?></font> </pre>

That seems to work for me or at least for what I need it to do.

John