【发布时间】:2023-12-08 10:26:01
【问题描述】:
好的,所以我有一个数据库并正在填充一个表。我通过 php 页面使用 $sqlCommand 连接和填充没有问题。
我的问题是我的一个领域有内容块/段落。我需要显示段落,但 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
请放轻松,因为我是新手。
【问题讨论】:
标签: php mysql line break paragraph