gpt4 book ai didi

php - Div 没有出现在 PHP echo 语句中,但在 echo 语句之外呈现良好

转载 作者:行者123 更新时间:2023-11-28 06:26:29 25 4
gpt4 key购买 nike

我不明白为什么我的照片 没有显示。 photosdiv 放在 echo 语句之外时显示良好,但在 echo 时它只是不呈现。我的 div 具有以下结构:

userposts_panel
photos_div
photos

这是包含所有 div 的代码(完整):

    <div class="userposts_panel">
<div class="photos_div">
<table>
<tr>
<?php
// get pictures from DB
$get_user_pics = mysqli_query ($connect, "SELECT * FROM user_photos WHERE uploaded_by='$username'"); // maybe $user
$check_rows = mysqli_num_rows ($get_user_pics);
while ($row = mysqli_fetch_assoc($get_user_pics)){
$user_id = $row ['id'];
$photo_url = $row ['img_url'];
$phot_desc = $row ['photo_desc'];
$photo_uploaded_by = $row ['uploaded_by'];
$photo_uloaded_on= $row ['uploaded_on'];
$uid = $row ['uid'];

echo "<td>
<div class='photos'>
<img src='$photo_url' height='170px' width='170px'/>
</div>
</td>";
}
?>
</tr>
</table>
</div>
</div>
</div>

.userposts_panel CSS:

.userposts_panel{
margin:0 auto;
height: auto;
text-align:left;
position:absolute;
top: 395px;
left:10px;
width: 800px;
background-color:#ffffff;
border-bottom: 1px solid #E1E3E4;
border-left: 1px solid #E1E3E4;
border-right: 1px solid #E1E3E4;
z-index:999;
}

.photos_div CSS:

.photos_div{
background-color: #FFFFFF;
width: 800px;
height: 500px;
}

.photos CSS:

.photos{
position:absolute;
top:0;
left:0;
margin-top:11px;
margin-left:5px;
background-color: #ffffff;
border: 1px solid red;
padding: 3px;
width: 200px;
height:200px;
margin-right: 5px;
text-align:center;
}

我只是不明白为什么 div 在 echo 时没有出现,但在 echo 语句之外呈现得很好?任何帮助将不胜感激。

最佳答案

尝试在 echo 语句中连接变量 $photo_url

   <div class="userposts_panel">
<div class="photos_div">
<table>
<tr>
<?php
// get pictures from DB
$get_user_pics = mysqli_query ($connect, "SELECT * FROM user_photos WHERE uploaded_by='$username'"); // maybe $user
$check_rows = mysqli_num_rows ($get_user_pics);
while ($row = mysqli_fetch_assoc($get_user_pics)){
$user_id = $row ['id'];
$photo_url = $row ['img_url'];
$phot_desc = $row ['photo_desc'];
$photo_uploaded_by = $row ['uploaded_by'];
$photo_uloaded_on= $row ['uploaded_on'];
$uid = $row ['uid'];
?>
<td>
<div class='photos'>
<img src='<?php echo $photo_url; ?>' height='170px' width='170px'/>
</div>
</td>
<?php
}
?>
</tr>
</table>
</div>
</div>

关于php - Div 没有出现在 PHP echo 语句中,但在 echo 语句之外呈现良好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35254765/

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