【发布时间】:2020-06-07 16:11:02
【问题描述】:
我正在制作我的第一个全栈项目。我做了这个博客,你可以在上面发帖和评论,所有的帖子和cmet都存储在mysqli数据库中。
为了在加载页面时获取数据库中的所有数据,我使用 php 将所有这些数据存储在一个数组中,然后在网页上回显这些数据。
它在页面上设置、获取和显示数据的部分很好。但是,当我从数组中回显数据(从数据库表中获取数据)时,文本会溢出我的 div……我用 CSS 和引导程序尝试了所有方法,但它不起作用。
我不知道为什么,我尝试了很多东西,但过去 2 天我一直卡在这个问题上。
请原谅我代码的不良做法,我是初级,主要是前端。这是我第一次尝试全栈项目,所以我在编写代码时自己学习。
<?php foreach($datas as $value): ?>
<?php
$id = $value['id'];
echo $id;
$imgSrc = $value['image'];
echo
"<div class='container-fluid' style='text-align: center; padding: 5% '>
<div class='row'>
<h1 id='titlePost' class='col-md-8 mx-auto'>" . $value['title'] . "</h1>".
"<hr class='w-50' style='height: 6px; background-color: #03fc84 !important; margin-left: auto; margin-right: auto;'>".
"
<div class='row col-12'>
<img src='$imgSrc' class='img-fluid col-md-4 mx-auto'>
</div>
<div class='container-fluid'>
<div class='row col-12'>
<p class='col-md-8' >" . $value['description'] . "</p>
</div>
</div>
".
"<p style='color: black; background-color: #03fc84;' class='w-50 mx-auto'>" . $value['date'] . "</p>".
"<div class='container-fluid'>
<div class='row col-md-12'>
<form action='".setComments($conn, $id, $sessionComments)."' method='post' enctype='multipart/form-data' class='col-md-8 mx-auto'>
<input name='comments' type='text' class='form-control' id='exampleFormControlInput1' >
选择要上传的图片:
<button type='submit' name='commentSubmit$id' id='btnSend' class='w-25 mx-auto btn btn-primary'>Comment
<i class='fas fa-paper-plane' style='font-size: 2.5rem; color : #ff6016; display: inline-block;'></i>
</button>
</form>
".
"
</div>
</div>
</div>
</div>";
// afficher les commentaires
getComments($conn, $commentsArray, $id);
?>
<?php endforeach ?>
【问题讨论】: