php mysql回车

时间:2013-06-16 21:34:30

标签: php mysql carriage-return

我是php / mysql的新手 我正在尝试为这部分做回车

echo "<td colspan='5'>" . nl2br($row['dish_description']) . "</td>";

“dish_description”包含一些包含“\ n”的文字 例如“配上沙拉和薄荷酱。\ n包含牛肉。”在mysql数据库中 但是我无法显示回车。我的代码在

之下
    <?php
    require_once 'login.php';
    $con = mysql_connect($db_hostname, $db_username, $db_password);
    mysql_select_db($db_database) or die("Unable to select database". mysql_error());

    $result = mysql_query("SELECT * FROM `dishes` ORDER BY `dishes`.`dish_id` ASC LIMIT 0 , 200");

    echo '<table align="center">
    ';

    while($row = mysql_fetch_array($result))
    {
    echo "<tr>";
    echo "<td style='width: 60px'></td>";
    echo "<th style='width: 100px'>Dish No</th>";
    echo "<td style='width: 70px'>" . $row['dish_id'] . "</td>";
    echo "<th style='width: 100px'>Dish Name</th>";
    echo "<td style='width: 120px'>" . $row['dish_name'] . "</td>";
    echo "<th style='width: 120px'>Dish Price</th>";
    echo "<td>£" . $row['dish_price'] . "</td>";
echo "</tr>";

echo "<tr>";
    echo "<td style='width: 75px'></td>";
    echo "<th style='width: 100px'>Vegetarian</th>";
    echo "<td style='width: 70px'>" . $row['dish_vegetarian']   ."</td>";
    echo "<td style='width: 100px'></td>";
    echo "<td style='width: 70px'></td>";
    echo "<th style='width: 120px'>Contains Nuts</th>";
    echo "<td style='width: 120px'>" . $row['dish_nuts']   ."</td>";
echo "</tr>";
echo "<tr>";
    echo "<td style='width: 75px'></td>";
    echo "<th style='width: 100px'>Information</th>";
    ***echo "<td colspan='5'>" . nl2br($row['dish_description']) . "</td>";***
echo "</tr>";
echo "<tr height='10px'>";
    echo "<td style='width: 75px'></td>";
    echo "<td style='width: 100px'></td>";
echo "</tr>";
    }
    echo "</table>";

    mysql_close($con);
?>  

我会非常感谢你的帮助。

亲切的问候 的Ish

1 个答案:

答案 0 :(得分:0)

在我看来,如果您echo将其作为HTML,则可以将<br>标记添加到数据库中的记录中。