gpt4 book ai didi

php - 样式使用户无论用户 ID 是什么,都能看到完全相同的样式

转载 作者:行者123 更新时间:2023-11-28 00:05:07 25 4
gpt4 key购买 nike

在我的代码中,我有一个中心标签并设置了中心标签的样式,使其看起来像我想要的样子。目前看起来像这样: picture here

每当我进入我的管理员帐户(一个与普通用户具有不同用户 ID 的帐户)时,它看起来与普通用户看到的大不相同。它看起来像这样: picture here

我想知道是否有任何解决方法,使它看起来就像普通人在管理员帐户上看到的一样。

我试过在它周围放置一个 div 标签并使用相同的样式功能,但这没有用。我试过将中心标记放在代码的不同部分周围,但由于它是一个“if”语句,它看起来会有所不同。

代码如下:

   <style>
center{
border-left: .17em dashed;
border-top: .17em solid;
border-right: .17em dashed;
border-bottom: .17em solid;
padding-left:25px;
padding-bottom: 20px;
width: 1000px;
background-color: #E1A0A0;
border-color: black;
margin: auto;
text-align: left;
}
</style>
<?php
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
echo '<center><b><h2>' . $row['title'] . '</h2></b>' . $row['post'] . '<br/><br/> <b>Posted On: </b>' . $row['postdate'] . '<br/><a href="comments.php?id=' . $row['blogid'] . '">View Post Comments</a> | ';
if($_SESSION['user_id'] == 3) {
echo '<a href="update.php?id=' . $row['blogid'] . '" >Update Blog Post</a> | <a href="' . basename(__FILE__) . '?id=' . $row['blogid'] . '" >Delete Blog Post</a></center>';

}
}
?>

我知道我不能在

"echo '<center><b><h2>' . $row['title'] . '</h2></b>' . $row['post'] . '<br/><br/> <b>Posted On: </b>' . $row['postdate'] . '<br/><a href="comments.php?id=' . $row['blogid'] . '">View Post Comments</a> |';"

部分代码和

"echo '<a href="update.php?id=' . $row['blogid'] . '" >Update Blog Post</a> | <a href="' . basename(__FILE__) . '?id=' . $row['blogid'] . '" >Delete Blog Post</a></center>';"

部分代码,因为它看起来像这样: picture here

此外,如果我将中心标记放在所有内容周围,它将如下所示: picture here

我只是想让它看起来无论谁看都一样。

最佳答案

if(){}收盘后你需要 echo '</center>'并将其从 if(){} 中移除.你已经设置了一个循环,有时 center没有关闭

echo '<center><b><h2>' . $row['title'] . '</h2></b>' . $row['post'] . '<br/><br/> <b>Posted On: </b>' . $row['postdate'] . '<br/><a href="comments.php?id=' . $row['blogid'] . '">View Post Comments</a> | ';
if($_SESSION['user_id'] == 3) {
echo '<a href="update.php?id=' . $row['blogid'] . '" >Update Blog Post</a> | <a href="' . basename(__FILE__) . '?id=' . $row['blogid'] . '" >Delete Blog Post</a>';
}
echo '</center>';

关于php - 样式使用户无论用户 ID 是什么,都能看到完全相同的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55752642/

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