Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

convert CR&LF to <br> PHP

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

convert CR&LF to <br> PHP

Postby scoobysteve » Fri Sep 13, 2013 4:44 am

Hi guys I have a database field that has a load of Bullet points added with a return so they appear on a new line, BUT in the resulting page they appear side by side is there something I can add to the following code to force a new line after each entry. I have managed to force it to upper case but I cant work out how to get them on a new line.
here is the link on how it looks right now http://algarveteamproperties.co.uk/search/run.php
I would love it to look like this.

BUILT IN 2006
152 SQM COVERED AREA
3 DOUBLE BEDROOMS WITH WOODEN FLOORING 2 WITH FITTED WARDROBES
1 BATHROOM (EN-SUITE)
FAMILY BATHROOM
LOUNGE/DINING ROOM
FULLY FITTED & EQUIPPED KITCHEN
OFFICE/STORAGE ROOM
TV AND TELEPHPNE POINTS IN ALL ROOMS
DOUBLE GLAZED & SHUTTERS ON ALL DOORS & WINDOWS
DAIKIN AIR CONDITIONING IN ALL ROOMS
CENTRAL VACUUM SYSTEM
PRIVATE GARDEN
PRIVATE TERRACE
COMMUNAL GARDENS AND SWIMMING POOL
CAR PORT
SMALL PRIVATE CONDOMINIUM
MAINS WATER, ELECTRICITY AND BOTTLED GAS
CLOSE TO ALL AMENITIES
EXCELLENT FOR PERMANENT RESIDENCE OR QUIET HOLIDAYS

thanks in advance Steve.

<?php
$con = mysql_connect("localhost","web215-listings","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("web215-listings", $con);
$result = mysql_query("SELECT * FROM tblproperties WHERE ID='301'");
while($row = mysql_fetch_array($result))
{
$Feature0 = $row['Bullet1'];
$upper = strtoupper($Feature0);
echo "$upper". "<br>";
}
mysql_close($con);
?>
Last edited by scoobysteve on Sat Sep 14, 2013 3:07 am, edited 1 time in total.
scoobysteve
New php-forum User
New php-forum User
 
Posts: 15
Joined: Thu May 31, 2012 1:08 am

Re: I need a Break added in the data ??

Postby johnj » Fri Sep 13, 2013 8:00 pm

use echo "<br/>"; or echo "<br/><br/>";
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: I need a Break added in the data ??

Postby scoobysteve » Sat Sep 14, 2013 1:01 am

thanks but all that will do is put a break at the end of the data, I need to explain as the data was entered into the single field at the end of each line the return was entered and the new line of the next bullet was entered so in a single field there is a CR&LF in there somewhere but when I use the code above it displays the data in one continuous line, I can sort it in classic asp code by using the following so I need the php equivalent.

Respond.write (ucase(replace(rsProperties("Bullet1"),chr(13) & chr(10),"<br />")))

what is the PHP equivalent please

Thanks
Steve
scoobysteve
New php-forum User
New php-forum User
 
Posts: 15
Joined: Thu May 31, 2012 1:08 am

Re: convert CR&LF to <br> PHP

Postby johnj » Sun Sep 15, 2013 5:37 am

please read about the built-in php function called,nl2br — Inserts HTML line breaks before all newlines in a string.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: convert CR&LF to <br> PHP

Postby scoobysteve » Sun Sep 15, 2013 9:29 am

Yes managed to sort it out by using the following

$pricey = nl2br(preg_replace('#(\\]{1})(\\s?)\\n#Usi', ']', stripslashes($row['Price1'])));
$upp = strtoupper($pricey);
echo $upp;
scoobysteve
New php-forum User
New php-forum User
 
Posts: 15
Joined: Thu May 31, 2012 1:08 am


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron