dongzhang8475 2018-03-09 17:14
浏览 67

嵌入html和CSS后,只显示登录用户返回的多行中的一行

I've been having a problem. I have this PHP code to return the logged in user's associated moduleID and moduleName.

Here is the code:

session_start();
//including the database connection file
include 'config.php';

$cuserID= $_SESSION['userID'];

//fetching data in descending order (lastest entry first)
//$result = mysql_query("SELECT * FROM users ORDER BY id DESC"); // mysql_query is deprecated
$result = mysqli_query($mysqli, "SELECT m.moduleID, m.moduleName
FROM modules m
JOIN courses c ON m.courseID = c.courseID
JOIN usersDemo u ON c.courseID = u.courseID
WHERE userID = '$cuserID'"); // using mysqli_query instead



        //while($res = mysql_fetch_array($result)) { // mysql_fetch_array is deprecated, we need to use mysqli_fetch_array 
       while($res = mysqli_fetch_array($result)) {     
        ?>
            <div id='loader-wrapper'>
                <div id='loader'><div id='loader1'> 
                  </div> 
                  </div>
            <p><a  onclick='redirectFunction("<?php echo $res['moduleID']; ?>");'><?php echo $res['moduleID']; ?></a></p>
            </div>
        <?php
        }
        ?>

and here is the output of this code:

moduleID's associated with Logged in user

I then tried to incorporate the rest of my CSS but when I did, it's only showing one row, and that one row has the last moduleID associated with my logged in user (in this case the moduleID is 3).

my resulting html:

<html>

<head>
    <meta charset="UTF-8">
    <title>Homepage</title>

    <!--Cascasing stylesheets -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/style.css">
    <style type="text/css">
        body {
            margin: 0;
            background: black url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/39132/bg-stars.gif) repeat 0 0;
            font-family: sans-serif;
            font-weight: 100;
        }
    </style>

</head>
<!-- Encorporated module nodes, number 1 in readme.txt that is wrapped around number 5 from readme.txt which is the sidebar -->

<body>
    <div class='wrapper'>
        <div class='sidebar'>
            <div class='title'>
                Menu
            </div>
            <ul class='nav'>
                <li>
                    <a href="index.php">Home</a>
                </li>
                <li>
                    <a href="index.php">Chat</a>
                </li>

                <li>
                    <a>Settings</a>
                </li>
                <li>
                    <a href='accounts/logout.php'>Logout</a>
                    <br/>
                </li>
            </ul>
        </div>
        <div class='content isOpen'>
            <a class='button'></a>
            <!-- Session variables used from login functionality, number 9 of readme.txt-->
            <!-- With guidance from  http://blog.chapagain.com.np/crud-create-read-update-delete-php-mysql-login-register/ -->
            <br/>
            <br/> Welcome James !
            <a href='logout.php'>Logout</a>
            <br/>
            <br/>
            <!-- <a href='index.php'>View and Add Products</a> -->
            <div class="second">


                <div id='loader-wrapper'>
                    <div id='loader'>
                        <div id='loader1'>
                        </div>
                    </div>
                    <p>
                        <a onclick='redirectFunction("1");'>1</a>
                    </p>
                </div>

                <div id='loader-wrapper'>
                    <div id='loader'>
                        <div id='loader1'>
                        </div>
                    </div>
                    <p>
                        <a onclick='redirectFunction("2");'>2</a>
                    </p>
                </div>

                <div id='loader-wrapper'>
                    <div id='loader'>
                        <div id='loader1'>
                        </div>
                    </div>
                    <p>
                        <a onclick='redirectFunction("3");'>3</a>
                    </p>
                </div>

            </div>
            <br/>
            <br/>
        </div>
    </div>
    <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>

    <script src="js/index.js"></script>

</body>

</html> 

Here is the output of this code

html output

and here is my associated CSS code:

@import url("https://fonts.googleapis.com/css?family=Open+Sans:400,600");
@import url("https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css");
*, *:before, *:after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100vh;
}

body {
  color: #333;
  background: black url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/39132/bg-stars.gif) repeat 0 0;
  overflow-x: hidden;
  height: 100%;
    font-family: sans-serif;
  font-weight: 100;
}


.wrapper {
  display: flex;
  min-height: 100%;
}

.sidebar {
  position: absolute;
  width: 220px;
}

.content {
  flex: 1;
  padding: 30px;
  background:  black url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/39132/bg-stars.gif) repeat 0 0;
  box-shadow: 0 0 5px black;
  transform: translate3d(0, 0, 0);
  transition: transform .3s;
}

.content.isOpen {
  transform: translate3d(220px, 0, 0);
}

.button {
  cursor: pointer;
}

.button:before {
  content: '\f0c9';
  font: 42px fontawesome;
}

/* Demo Navigation */
.title {
  font-size: 16px;
  line-height: 50px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 7px;
  color: #eee;
  border-bottom: 1px solid #222;
  background: #2a2a2a;
}

.nav li a {
  position: relative;
  display: block;
  padding: 20px 0 20px 50px;
  font-size: 12px;
  color: #eee;
  border-bottom: 1px solid #222;
}

.nav li a:before {
  font: 14px fontawesome;
  position: absolute;
  top: 19px;
  left: 20px;
}

.nav li:nth-child(1) a:before {
  content: '\f00a';
}

.nav li:nth-child(2) a:before {
  content: '\f012';
}

.nav li:nth-child(3) a:before {
  content: '\f0e8';
}

.nav li:nth-child(4) a:before {
  content: '\f0c3';
}

.nav li:nth-child(5) a:before {
  content: '\f022';
}

.nav li:nth-child(6) a:before {
  content: '\f115';
}

.nav li:nth-child(7) a:before {
  content: '\f085';
}

.nav li:nth-child(8) a:before {
  content: '\f023';
  left: 23px;
}

.nav li a:hover {
  background: #444;
}

.nav li a.active {
  box-shadow: inset 5px 0 0 #5b5, inset 6px 0 0 #222;
  background: #444;
}






/* Added background Gif, stars are glowing */


.container{
  display: flex;
   flex-direction: row;
}
.container div:first-child(1){
  background-color:#ccffcc;
  flex: 1;
  height:100px;
  width:100px;


}
.first {
  -webkit-flex: 2;
          flex: 2:

}
.second {
  -webkit-flex: 2;
          flex: 2;

}
.third {
  -webkit-flex: 3;
          flex: 3;
}
#lnav{
  display:none;
}
#rnav{
  display:none;
}

.nav ul li a{
text-decoration: none; 
  color:#b3e0ff;
  text-shadow: 0 0 15px #2187e7;
  border: 1px solid #b3e0ff;
   padding:10px;
  margin:10px;
   box-shadow: 0 0 5px #2187e7;

}



p{
  z-index: 999;
  margin-left:66px;
  font-size:46px;
  margin-top:-26px;
  color:#fff;/*4db8ff*/
  padding:0px;
  position:relative;
-webkit-animation: neon2 1.5s ease-in-out infinite alternate;
  -moz-animation: neon2 1.5s ease-in-out infinite alternate;
  animation: neon2 1.5s ease-in-out infinite alternate;
text-shadow: 0 0 15px #b3e0ff;

}

p2{
  z-index: 999;
  margin-left:200px;
  font-size:42px;
  margin-top:-26px;
  color:#fff;/*4db8ff*/
  padding:0px;
  position:relative;
-webkit-animation: neon2 1.5s ease-in-out infinite alternate;
  -moz-animation: neon2 1.5s ease-in-out infinite alternate;
  animation: neon2 1.5s ease-in-out infinite alternate;
text-shadow: 0 0 15px #b3e0ff;

}

p3{
  z-index: 999;
  margin-left:260px;
  font-size:42px;
  margin-top:-26px;
  color:#fff;/*4db8ff*/
  padding:0px;
  position:relative;
-webkit-animation: neon2 1.5s ease-in-out infinite alternate;
  -moz-animation: neon2 1.5s ease-in-out infinite alternate;
  animation: neon2 1.5s ease-in-out infinite alternate;
text-shadow: 0 0 15px #b3e0ff;

}


#loader-wrapper{
    position: fixed;
    top: 200px;
    left:18%;
    width: 300px;
    height: 300px;
   margin-left:30px;
    float: left;
}

 /* I have added more loader-wrapper's to add extra module nodes
Loader wraooers are floating right instead of left & margin has been changed*/   
#loader-wrapper1{
    position: fixed;
    top: 200px;
    left:18%;
    width: 300px;
    height: 300px;
   margin-left:30px;
    float: right;
  margin-left: 360px;

}

#loader-wrapper2{
    position: fixed;
    top: 200px;
    left:18%;
    width: 300px;
    height: 300px;
   margin-left:30px;
    float: right;
  margin-left: 700px;

}


#loader {
    display: block;
    position: relative;
    left: 50%;
    top: 50%;
    width: 100%;
    height: 100%;
    margin: -175px 0 0 -175px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: #4db8ff;
  border-bottom-color: #b3e0ff;
  border-right-color: #66c2ff;
  border-left-color: #80ccff;
  box-shadow: 0 0 15px #2187e7;

    -webkit-animation: spin 30s linear infinite; /* Chrome, Opera 15+, Safari 5+ */
    animation: spin 30s linear infinite; /* Chrome, Firefox 16+, IE 10+, Opera */
}

#loader1:before {
    content: "";
    position: absolute;
    top: 70px;
    left: 70px;
    right: 70px;
    bottom: 70px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-color: #4398ba;

    border-style:dotted;

    -webkit-animation: spin 18s linear infinite; /* Chrome, Opera 15+, Safari 5+ */
      animation: spin 18s linear infinite; /* Chrome, Firefox 16+, IE 10+, Opera */
}

#loader1:after {
    content: "";
    position: absolute;
    top: 55px;
    left: 55px;
    right: 55px;
    bottom: 55px;
    border-radius: 50%;
    border-color: #59c1eb;
   border-width:5px;    
    border-style:double dashed solid dotted ;
  box-shadow: 0 0 40px #2187e7;
    -webkit-animation: spin 60s linear infinite; /* Chrome, Opera 15+, Safari 5+ */
      animation: spin 60s linear infinite; /* Chrome, Firefox 16+, IE 10+, Opera */
}


#loader:before {
    content: "";
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    bottom: 15px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-color: #1d5ca9;

    border-style:dotted;

    -webkit-animation: spin 18s linear infinite; /* Chrome, Opera 15+, Safari 5+ */
      animation: spin 18s linear infinite; /* Chrome, Firefox 16+, IE 10+, Opera */
}

#loader:after {
    content: "";
    position: absolute;
    top: 25px;
    left: 25px;
    right: 25px;
    bottom: 25px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-color: #429bc0;
   border-width:5px;    
    border-style:dotted solid;
    -webkit-animation: spin 60s linear infinite; /* Chrome, Opera 15+, Safari 5+ */
      animation: spin 60s linear infinite; /* Chrome, Firefox 16+, IE 10+, Opera */
}

Therefore, If i use my code without embedding html & CSS, it shows ALL moduleID's associated, although if I include my css, it only shows one row and shows the last moduleID. Any thoughts?


EDIT

With help provided in the answers, I have changed the element id's to classes for id='loader-wrapper'>, <div id='loader'>, and <div id='loader1'>. Now all rows of moduleID attached to the logged in user is show but for some reason, my spinners cease to work.

This is the output of the change:

Output when element id's changed to classes

This is the CSS code for my spinners:

@-webkit-keyframes spin {
    0%   {
        -webkit-transform: rotate(0deg);  /* Chrome, Opera 15+, Safari 3.1+ */
        -ms-transform: rotate(0deg);  /* IE 9 */
        transform: rotate(0deg);  /* Firefox 16+, IE 10+, Opera */
    }
    100% {
        -webkit-transform: rotate(360deg);  /* Chrome, Opera 15+, Safari 3.1+ */
        -ms-transform: rotate(360deg);  /* IE 9 */
        transform: rotate(360deg);  /* Firefox 16+, IE 10+, Opera */
    }
}
@keyframes spin {
    0%   {
        -webkit-transform: rotate(0deg);  /* Chrome, Opera 15+, Safari 3.1+ */
        -ms-transform: rotate(0deg);  /* IE 9 */
        transform: rotate(0deg);  /* Firefox 16+, IE 10+, Opera */
    }
    100% {
        -webkit-transform: rotate(360deg);  /* Chrome, Opera 15+, Safari 3.1+ */
        -ms-transform: rotate(360deg);  /* IE 9 */
        transform: rotate(360deg);  /* Firefox 16+, IE 10+, Opera */
    }
}


@-webkit-keyframes neon2 {
  from {
    text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #228DFF, 0 0 70px #228DFF, 0 0 80px #228DFF, 0 0 100px #228DFF, 0 0 150px #228DFF;
  }
  to {
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #228DFF, 0 0 35px #228DFF, 0 0 40px #228DFF, 0 0 50px #228DFF, 0 0 75px #228DFF;
  }
}

Any thoughts?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮