doupiao1893 2019-04-18 19:31
浏览 82
已采纳

样式化使用户无论用户ID是什么,都可以看到相同的样式

In my code, I have a center tag and have styled the center tag so it looks the way I want it to look. It currently looks like this: picture here

Whenever I go on my admin account (one that has a different user id than the normal users) it looks way different than if a regular user would see it. It looks like this: picture here

I would like to know if there is any way around this so it looks the same as if a regular would see it on an admin account.

I've tried putting a div tag around it and using the same styling features, but that didn't work. I've tried putting the center tag around different parts of the code, but since it's an "if" statement, it will look different.

Here is the code:

   <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>';

        }
    }
    ?>

I know that I can't just put another center tag around the

"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> |';"

part of the code and

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

part of the code because it will look like this: picture here

Additionally, if I put the center tag around everything, it will look like this: picture here

I just want to make it look the same no matter who views it.

  • 写回答

2条回答 默认 最新

  • douyannuo7733 2019-04-18 20:32
    关注

    after the close of the if(){} you need to echo '</center>' and remove it from inside the if(){}. You have setup a loop where sometimes center is not closed

    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>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler