如何使用mysql的javascript提取格式显示数据?

时间:2013-04-09 05:31:13

标签: php javascript html

当我从数据库中提取时以及当我想在新行中显示“Exception”时,这就是我在视图中呈现数据的原因。但是我希望以单一的方式以适当的方式显示它们

The requirements of this chapter apply to the following: (1) New buildings or portions thereof used as health care occupancies (see 1.4.1) (2) Additions made to, or used as, a health care occupancy (see 4.6.6 and 18.1.1.4) Exception: The requirement of 18.1.1.1.1 shall not apply to additions classified as occupancies other than health care that are separated from the health care occupancy in accordance with 18.1.2.1(2) and conform to the requirements for the specific occupancy in accordance with Chapters 12 through 17 and Chapters 20 through 42, as appropriate.(3) Alterations, modernizations, or renovations of existing health care occupancies (see 4.6.7 and 18.1.1.4) (4) Existing buildings or portions thereof upon change of occupancy to a health care occupancy (see 4.6.11) Exception*: Facilities where the authority having jurisdiction has determined equivalent safety has been provided in accordance with Section 1.5.

我想在动态

中按以下顺序显示

本章的要求适用于以下内容:

(1) New buildings or portions thereof used as health care occupancies (see 1.4.1)

 (2) Additions made to, or used as, a health care occupancy (see 4.6.6 and 18.1.1.4) 

Exception: The requirement of 18.1.1.1.1 shall not apply to additions classified as occupancies other than health care that are separated from the health care occupancy in accordance with 18.1.2.1(2) and conform to the requirements for the specific occupancy in accordance with Chapters 12 through 17 and Chapters 20 through 42, as appropriate.

(3) Alterations, modernizations, or renovations of existing health care occupancies (see 4.6.7 and 18.1.1.4) 

(4) Existing buildings or portions thereof upon change of occupancy to a health care occupancy (see 4.6.11) Exception*: Facilities where the authority having jurisdiction has determined equivalent safety has been provided in accordance with Section 1.5.

虽然我在javascript中这样做。我在section_data.title中获取此内容的位置。我怎样才能做到这一点。

2 个答案:

答案 0 :(得分:0)

我觉得你的换行符不是html。尝试在PHP中使用str_replace('\n', '<br>', $queryResultString);,然后将其编码为JSON(将$ queryResultString替换为您通过JSON发送的任何字符串)。

让我知道这是否有效,或者我们可以尝试别的东西。

答案 1 :(得分:0)

使用JavaScript方法“String [] split(String regex)”根据正则表达式拆分字符串并存储在数组中。然后您可以添加breakline标记来格式化它。