Php 数据库项输出不正确

Php 数据库项输出不正确,php,html,mysql,Php,Html,Mysql,我无法让我的网站正确显示数据库条目。我将带换行符的格式化文本复制粘贴到MySQL数据库中。如果我在终端中查看条目,它将正确显示带有换行符的信息。当我在浏览器中查看时,虽然它是全部输出,但它忽略了所有格式规则,并使其成为一个长文本字符串,刚好到达DIV的边缘,并创建一个没有任何格式的新行。我是新来的,所以如果我的问题似乎含糊不清,我提前道歉,只是问任何额外的信息,你可能会发现有用的提供一个准确的解决方案 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01

我无法让我的网站正确显示数据库条目。我将带换行符的格式化文本复制粘贴到MySQL数据库中。如果我在终端中查看条目,它将正确显示带有换行符的信息。当我在浏览器中查看时,虽然它是全部输出,但它忽略了所有格式规则,并使其成为一个长文本字符串,刚好到达DIV的边缘,并创建一个没有任何格式的新行。我是新来的,所以如果我的问题似乎含糊不清,我提前道歉,只是问任何额外的信息,你可能会发现有用的提供一个准确的解决方案

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>
        Test Site!    
        </title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <LINK href="CLLProfile.css" rel="stylesheet" type="text/css">
                    <script language="javascript" type="text/javascript">


// Roshan's Ajax dropdown code with php
// This notice must stay intact for legal use
// Copyright reserved to Roshan Bhattarai - nepaliboy007@yahoo.com
// If you have any problem contact me at http://roshanbh.com.np
function getXMLHTTP() { //function to return the xml http object
        var xmlhttp=false;  
        try{
            xmlhttp=new XMLHttpRequest();
        }
        catch(e)    {       
            try{            
                xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e){
                try{
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch(e1){
                    xmlhttp=false;
                }
            }
        }

        return xmlhttp;
    }

    function getCategory(CatID) {       

        var strURL="Categories.php?category="+CatID;
        var req = getXMLHTTP();

        if (req) {

            req.onreadystatechange = function() {
                if (req.readyState == 4) {
                    // only if "OK"
                    if (req.status == 200) {                        
                        document.getElementById('categorydiv').innerHTML=req.responseText;                      
                    } else {
                        alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                    }
                }               
            }           
            req.open("GET", strURL, true);
            req.send(null);
        }       
    }

    function getSub(CatID) {        

        var strURL="SubCategories.php?category="+CatID;
        var req = getXMLHTTP();

        if (req) {

            req.onreadystatechange = function() {
                if (req.readyState == 4) {
                    // only if "OK"
                    if (req.status == 200) {                        
                        document.getElementById('subcategorydiv').innerHTML=req.responseText;                       
                    } else {
                        alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                    }
                }               
            }           
            req.open("GET", strURL, true);
            req.send(null);
        }       
    }

</script>

    </head>

    <body>
        <div id="wrapper">
        <div class="container">

            <div id="header">
                <a href="index.php"><img src="images/Logo.jpg"></a>

                <div class="login"> 
                    <a href="register.php">Sign Up</a> <a href="main_login.php">Login</a>
                </div>

                <div class="search">
                    <form id ="search" action="" method="post" enctype="multipart/form-data">
                        <label>Search:</label>
                        <input type="text" name="searchBox" id="searchBox" /> 
                        <input type="submit" id="Submit" value="Submit" />
                    </form> 
                </div>

            </div>

            <div class="navigation">

                <form id ="categoryForm" action="businesses.php" method="post">
                    <div id="categorydiv">
                        <select name="thing" onChange="getSub(this.value)">
                            <option value=0>Select Main Category<?=$options?>
                        </select> </div>

                    <div id="subcategorydiv">
                        <select name="subCats" >
                             <option>Select Sub Category</option>
                        </select></div>

                        <input type="submit" value="Submit" id="Submit" />
                </form>
                </div>


                <div class="content">

                   <?PHP                             


                     echo "<img src=" . "users/" . $username . "/images/" . $logo . " " . "width=" . "200" . " " . "height=" . "auto" . " " . "border=" . "0" . "/>" . "</a>" . "<br>";


                  ?>

                    <div class="description">

                   <?PHP                             
                     echo "<h2>" . $name . "</h2>";
                     echo "<p>" . $description . "</p>";

                  ?>
                    </div>



                    </div>
                </div>

        </div>


    </body>

</html>

试验场!
//Roshan使用php编写的Ajax下拉代码
//此通知必须保持完整,以便合法使用
//版权归Roshan Bhattarai所有-nepaliboy007@yahoo.com
//如果您有任何问题,请联系我http://roshanbh.com.np
函数getXMLHTTP(){//返回xml http对象的函数
var xmlhttp=false;
试一试{
xmlhttp=新的XMLHttpRequest();
}
第(e)款{
试试{
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
捕获(e){
试一试{
xmlhttp=新的ActiveXObject(“Msxml2.xmlhttp”);
}
渔获物(e1){
xmlhttp=false;
}
}
}
返回xmlhttp;
}
函数getCategory(CatID){
var strURL=“Categories.php?category=“+CatID;
var req=getXMLHTTP();
如果(请求){
req.onreadystatechange=函数(){
如果(req.readyState==4){
//只有在“OK”的情况下
如果(请求状态==200){
document.getElementById('categorydiv')。innerHTML=req.responseText;
}否则{
警报(“使用XMLHTTP:\n“+req.statusText时出现问题”);
}
}               
}           
请求打开(“获取”,strURL,true);
请求发送(空);
}       
}
函数getSub(CatID){
var strURL=“SubCategories.php?category=“+CatID;
var req=getXMLHTTP();
如果(请求){
req.onreadystatechange=函数(){
如果(req.readyState==4){
//只有在“OK”的情况下
如果(请求状态==200){
document.getElementById('subcategory div')。innerHTML=req.responseText;
}否则{
警报(“使用XMLHTTP:\n“+req.statusText时出现问题”);
}
}               
}           
请求打开(“获取”,strURL,true);
请求发送(空);
}       
}
搜索:
选择主要类别
选择子类别
文本Im粘贴到MySQL数据库中,在描述字段中输出:

1930年,查尔斯·海德(Charles Hyde)和大卫·维登堡(David Vredenburg)在爱荷华州比康斯菲尔德(Beaconsfield)开了一家小型百货商店。那家商店发展成为Hy-Vee,一家以优质服务和低价著称的公司。作为一家员工所有的公司,Hy-Vee鼓励56000多名员工帮助指导公司

我们的杰出成就表明了他们的辛勤工作和清晰的愿景。通过他们的努力,Hy-Vee这个名字已经成为优质产品、低价和优质客户服务的代名词。我们的口号“每一条通道都有帮助的微笑”,表达了我们企业哲学的基础。 Hy Vee是中西部消费者对饮食、营养和健康主题信息需求的试金石。以天然和有机产品为特色的健康市场部门;店内营养师的咨询服务;NuVal营养评分系统;消费者和员工健康计划;而Hy Vee铁人三项赛则强调了公司对健康生活方式的承诺

我们的公司办公室位于爱荷华州的西得梅因。Hy Vee校区包括一个12000平方英尺的会议中心,用于会议、培训和继续教育项目

我们的分销业务总部位于爱荷华州的查里顿,在那里我们拥有150多万平方英尺最先进的仓库空间。另一个大型配送中心位于爱荷华州切诺基市,占地65万平方英尺,用于销售干粮产品和通用美孚

Hy Vee销售额超过73亿美元,在中西部八个州拥有235家零售店,跻身美国前20家连锁超市和前50家私营公司之列。《超市新闻》是食品行业的权威声音,因其在提供促进健康生活方式的服务和项目方面的领先地位,该公司获得了“全健康企业奖”。

换行符(“\n”和/或“\r”)需要转换为换行符(
),才能在web浏览器中正确显示

str_replace("\n", "<br />", "My string\n has line breaks");
str\u替换(“\n”、“
”、“我的stri”
echo "<p>".str_replace("\n", "</p><p>", "My string\n has line breaks")."</p>";
$text = "some\ntext\nwith new lines";
$text = nl2br($text);
some<br />
text<br />
with new lines
   echo "<h2>" . nl2br(htmlentities($name)) . "</h2>";
   echo "<p>" . nl2br(htmlentities($description)) . "</p>";