gpt4 book ai didi

php-mysql 回车

转载 作者:行者123 更新时间:2023-11-30 01:34:01 24 4
gpt4 key购买 nike

我对 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);
?>

最佳答案

我认为如果你echo作为 HTML,您只需添加 <br>为您在数据库中的记录添加标签。

关于php-mysql 回车,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17137948/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com