2
好吧,所以我有一个数据库,并填充一个表。我通过php页面连接并填充$ sqlCommand没有问题。如何在mysql中显示段落?
我的问题是我的一个领域有块/段的内容。我需要显示段落,但nl2br()不起作用。
这里是我如何填充(site.com/xtblcreate.php):
// Create table1 in db x for storing words
$sqlCommand = "CREATE TABLE table1 (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
a TEXT,
b TEXT,
c TEXT,
d TEXT,
page_views INT NOT NULL default '0',
FULLTEXT (a,b,c,d)
) ENGINE=MyISAM";
$query = mysql_query($sqlCommand) or die(mysql_error());
echo "<h3>Success creating table1 in db x</h3>";
// Insert dummy data into the table1 in db x
$sqlCommand = "INSERT INTO table1 (a,b,c,d) VALUES
('something', 'something else', 'a lot \n of info', 'quick conclusion')";
我需要的是“大量的信息”被打破像两段。
然后它自己的PHP页面查询(site.com/x.php):
$search_output .= "$count result(s) for <strong>$searchquery</strong><br />";
while($row = mysql_fetch_array($query)){
$id = $row["id"];
$a = $row["a"];
$b = $row["b"];
$c = $row["c"];
$d = $row["d"];
$search_output .= "*<br>$a- <br/><b>c: </b>$c<br /> <br /> b: $b<br />finally, d: $d<br/>";
echo nl2br($c);
//output $c with paragraphs
请宽容我,因为我在这是新。
但是nl2br()用在右侧区域(在进程的查询部分,而不是在表格填充页面中)?此外,由于我正在使用完整句子,会“影响句点处理吗?我不熟悉” –
nl2br用于右侧区域,但数据未插入任何换行符,因为未转义转义进入实际的换行。在继续之前,您应该阅读[本页](http://www.php.net/manual/en/language.types.string.php)。 – drew010
很多要在该页面中处理。但根据PHP手册,双引号应该可以解决问题。我理解正确吗? –