Hi
What would be the best practice to format my text in MySQL without messing around in php?
For example, I have a description:

TECHNICAL FEATURES: 
Anti static, dust repellent,...

COLOURS AVAILABLE:
- WHITE
- BLACK

I'm copying everything from my old website (html-only) into my database, and this is what it outputs in php:

TECHNICAL FEATURES: Anti static, dust repellent,... COLOURS AVAILABLE: -WHITE -BLACK

Is there any way to keep the formatting ?
When I just copy it in there, there are no line breaks. Is there a solution to this?

If you copied and pasted the text, it should have preserved the line breaks. These however do not show in HTML and need to be converted to break <br /> tags.

There's a handy function in PHP for doing this called nl2br();. Simply pass your string through that before displaying.

E.g.

$string = 'TECHNICAL FEATURES: Anti static, dust repellent,... COLOURS AVAILABLE: -WHITE -BLACK';
echo nl2br($string);
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.