[英]Admin Panel: enter text, post to database, blog style
I'm trying to re-create my fire department's website, as it's strictly a HTML website, and far from professional. 我正在尝试重新创建消防部门的网站,因为它严格来说是HTML网站,而且远非专业。 Everything is going excellently, including the log in system and pave navigation.
一切都很顺利,包括登录系统和铺装导航。 However, I've run into a slight bump in the road that might be beyond my current skill level:
但是,我遇到了可能超出我当前技能水平的小障碍:
How do I have the person who's logged into the admin panel, enter information in a blog-like style, to post it to the front page (such as a news post / website announcement)? 我如何让登录到该管理控制台的人以类似博客的方式输入信息,然后将其发布到首页(例如新闻发布/网站公告)?
It's actually a lot like this post here - Editor tools at the top, and when it posts, it has the formatting and breaklines. 实际上与这里的帖子很像-顶部的编辑器工具,并且在发布时具有格式和换行符。 When I put it in my database, it shows up as one clump wall of text, with no formatting.
当我将其放在数据库中时,它显示为一堵无格式的文本墙。
INDEX.PHP 索引库
<?
$qnews = mysqli_query($link, "SELECT * FROM news WHERE archive = 0 ORDER BY time DESC");
while($rownews = mysqli_fetch_array($qnews))
{
if(empty($rownews))
{
echo "<div class=\"news\"><h2>There are no announcements posted.</h2></div>";
}
else
{
echo "<div class=\"news\">";
echo "<h2>";
echo $rownews['title'];
echo "</h2><p>";
echo $rownews['body'];
echo "</p><br />";
echo "<span class=\"newsfooter\">Posted on <font color=\"#FA0000\">";
echo date("F d Y @ H:i", strtotime($rownews['time']));
echo "</font> by <font color=\"#0000FA\">";
echo $rownews['creator'];
echo "</font></span></div>";
}
}?>
MySQL Table MySQL表
news
-- id (A_I) (UNIQUE)
-- title VARCHAR(50)
-- body VARCHAR(5000)
-- created DATETIME(25) Default:CURRENT_TIMESTAMP
-- edited DATETIME(25)
-- archived INT(1) Default:0
Am I way out of my league, or can someone point me in the right direction? 我是走出联盟的道路,还是有人可以指出正确的方向?
I think changing 我认为改变
echo $rownews['body'];
to 至
echo nl2br($rownews['body']);
can give you at least the linebreaks, if they are present in the text stored in the database. 如果数据库中存储的文本中包含换行符,则至少可以给您换行符。 Concerning additional formatting, it would be interesting to see how is a single entry represented in the database (or in the HTML output), could you add that to your question?
关于其他格式,有趣的是查看数据库(或HTML输出)中如何表示单个条目,您可以将其添加到问题中吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.