Jump to content

Newbie, spacing out an article....sorry!


hodgey87

Recommended Posts

Hi Everyone,

 

Ive been asked to try and convert our small website into PHP, im not a web developer but im going to give it a try :D

 

Basically we have a news page, i can get all the text to print out onto the page its just theres no formating at all it comes out like this:

 

转会合约丑闻之后,鲁尼在周六重返曼联,在下半场被替换上场。在周六的比赛中,曼联坐镇主场迎战来访的维冈,最终以2:0战胜维冈。 这个英格兰射手终于走出膝盖受伤的阴影重返曼联,加入曼联争夺英超和欧冠的阵营。 “我已经签了新合约,我未来的足球生涯是和曼联联系在一起的”鲁尼在重返赛场之后接受采访时说。 “周六赛场上的球迷真的非常让我感动。我离开了很长的时间,如果我说我一点都不担心球迷的反应,那绝对是骗人。看到他们对我的接纳我真的松了一口气,我会尽我所能帮助球队多进球” “我可以理解合约谈判对球迷们造成的影响。各大媒体的介入使得整个事件更加复杂,对球迷而言则更加难以接受。” “但是对我和球队来说,最重要的是我们最终达成了共识签订了合约。” 鲁尼还透露说他的队友们张开双臂欢迎他的回归,他会努力成为未来球队的支柱。 这位英格兰足球巨星还表示“我会像当年吉格斯,内维尔和斯科尔斯帮助我那样帮助年轻的球员。” “我想要留在曼联,尽我所能使俱乐部取得更多的胜利。我从始至终都是想要留在曼联的。” “我的确有自己的想法也表明了我的立场,但是不管怎么说我真的很高兴最终留在曼联。”

 

I ideally need to add a break after each line in the text, ive searched around but dont really understand it all to be honest. This is the code im using to extract the article:

 

<?php

mysql_connect("localhost", "web148", "123") or die(mysql_error());
mysql_select_db("web148") or die(mysql_error());

mysql_query("SET names 'utf8'");
$result = mysql_query("SELECT body FROM article WHERE ID='1'");


$row = mysql_fetch_array( $result );
echo $row['body'];


?> 

 

If anyone could point me in the right direction id appreciate it  :P

Link to comment
https://forums.phpfreaks.com/topic/221859-newbie-spacing-out-an-articlesorry/
Share on other sites

Thank you for your reply, i tried this from some sample code:

 

mysql_connect("localhost", "web148-cuju8", "game8123") or die(mysql_error());
mysql_select_db("web148-cuju8") or die(mysql_error());
mysql_query("SET names 'utf8'");
$result = mysql_query("SELECT body FROM article WHERE ID='1'");
$row = mysql_fetch_array( $result );
[b]echo nl2br(htmlentities($row['body']));[/b]

 

But the text all comes out like:

 

转��约������尼������������被�����������中

 

 

---edit----

 

Sorry just modified it slight to

 

echo nl2br($row['body']);

 

works perfect

 

thanks you

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.