php - 当我在论坛中发布来自 mysql 数据库的数据时,它们不会堆叠
问题描述
我的论坛有问题,当我尝试在我的论坛上发布用户帖子时,帖子继续在同一行上,而不是像它应该的那样堆叠(段落)。此外,当我的数据库中有大量数据时,它只会让我的整个网站更宽,而不是堆叠文本。
目前我正在使用 php 并将我的数据存储在 mysql 数据库中,数据正确来自数据库。但同样是我的数据库中的数据如何显示的问题。
Html/php code:
<?php
require "header.php";
include 'includes/dbh.inc.php';
?>
<body>
<div class="container">
<form action="aalesund.php" method="POST">
<div class="row">
<div class="col-25">
<label for="subject">Subject</label>
</div>
<div class="col-75">
<input type="text" name="subject" placeholder="Subject">
</div>
</div>
<div class="row">
<div class="col-25">
<label for="content">Content</label>
</div>
<div class="col-75">
<textarea type="text" name="content" placeholder="Write something..."
style="height: 200px"></textarea>
</div>
</div>
<div class="row">
<div class="col-25">
<label for="date">Date and time</label>
</div>
<div class="col-75">
<input type="text" name="date" placeholder="Please write the date and
time">
</div>
<div class="button-container">
<button class="postButton" type="submit" name="submit">Write
post</button>
</div>
</form>
<?php
$subject = $_POST['subject'];
$content = $_POST['content'];
$date = $_POST['date'];
$sql = "INSERT INTO posts (subject, content, date) VALUES ('$subject',
'$content', '$date');";
$result = mysqli_query($conn, $sql);
header("Location ../aalesund.php?post=succsesfull");
$sql = "SELECT * FROM posts ORDER BY id DESC;";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
while ($row = mysqli_fetch_assoc($result)) {
?>
<article class="forum">
<h1 style="font-size: 20px"><?php echo $row['subject']; ?></h1>
<p class="forumContent"><?php echo $row['content']; ?></p>
<p class="forumDate"><?php echo $row['date']; ?></p>
</article>
<?php
}
}
?>
<?php
require "footer.php";
?>
Part of the css code:
.forumContent {
text-align: center;
}
.forumDate {
text-align: right;
color: #ff9933;
}
.forum {
background-color: #FFFFFF;
margin: 5px;
padding-left: 20px;
padding-right: 20px;
}
(对不起意大利面条代码)
解决方案
推荐阅读
- octave - 在 Octave 中线性转换 RGB 图像的颜色空间
- python - 为什么保存后图像大小会改变?
- http - 如何锁定(或使不可能)从网站下载的媒体
- javascript - 从 base64 URI Phaser 3 加载纹理图集
- java - 带有循环、字符串输入和 .equals(" ") 方法的 Java 应用程序
- math - 如何在使用阴影展平矢量以使其呈现在同一位置时计算 delta X、Y?
- vb.net - 如何在 WebView 控件中显示链接的 PDF 文档
- javascript - 处理 Promise.all 中的错误 - 承诺拒绝 + 类型错误
- python - Python 三元运算顺序
- python - 在 sqlalchemy 中插入带有外键的记录的正确方法