zoukankan      html  css  js  c++  java
  • 2016/3/26 weixin 头像 昵称 网页优化显示 缺表中数据 只有代码 无显示效果

    weixin.php

     1 <!DOCTYPE html>
     2 <html lang="en">
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Document</title>
     6     <style type="text/css">
     7     *
     8     {   /*清格式*/
     9         margin:0px auto; /*auto自动居中*/
    10         padding:0px;
    11         font-family:微软雅黑;
    12     }
    13     #list
    14     {
    15          350px;height: 400px;
    16     }
    17     .py
    18     {    margin:8px 0px 0px 0px;
    19         350px; height: 35px;
    20     }
    21     .py:hover  /*鼠标点击时变色*/
    22     {
    23         background-color:#639;
    24         color:#FFF;
    25         cursor:pointer;/*鼠标变成手*/
    26     }
    27     .img
    28     {
    29         35px; height: 35px;
    30         float:left;
    31     }
    32     .nc
    33     {
    34         float:left;    
    35         height: 35px;
    36         margin:0px 0px 0px 20px;
    37         line-height: 35px;
    38         vertical-align: middle;
    39     }
    40     </style>
    41 </head>
    42 <body>
    43  <?php
    44     $uid="18653378660";
    45  ?>
    46  <div id="list">
    47      <?php
    48     //连接对象
    49     $db=new MySQLi("localhost","root","123","weixin");
    50     //判断是否连接成功
    51     !mysqli_connect_error()or die("连接失败!");
    52     //写SQL语句
    53     $sql="select Friends from friends where Uid='$uid'";
    54     //执行Sql语句
    55     $result=$db->query($sql);
    56     $arr=$result->fetch_all();
    57 
    58     for ($i=0; $i <count($arr) ; $i++) 
    59     { 
    60         //朋友的用户名
    61         $fuid=$arr[$i][0];
    62         //查USERS表,根据朋友的UID查出头像和昵称
    63         $sqlf="select NickName,Pic from Users where Uid='$fuid'";
    64         $result=$db->query($sqlf);
    65         $arrf=$result->fetch_row();
    66         echo "<div onclick='ShowCode(this)' class='py'><img src='$arrf[1]' class='img'/><div class='nc'>$arrf[0]</div></div>";
    67 
    68     }
    69 
    70      ?>
    71  </div>
    72  <script type="text/javascript">
    73      function ShowCode(div)
    74      {    var d=document.getElementByClassName('py');
    75          for (var i = 0; i < d.length; i++)
    76           {
    77               d[i].style.backgroundColor="#FFF";
    78               d[i].style.color="#000";
    79          }
    80          div.style.backgroundColor="#639";
    81          div.style.color="#FFF";
    82 
    83          alert(div.getAttribute("bs"));
    84      }
    85  </script>
    86 </body>
    87 </html>
  • 相关阅读:
    夜神 虚拟机调试 HBuilder 移动端应用
    maven filter 文件分环境打包部署小问题
    fatal: remote error: CAPTCHA required
    程序员今年是这样计划的
    线程池shutdown与shutdownnow 小例子
    JAVA知识点脉络记忆-刻意练习
    日志
    (职员)2015-12-02 星期三 日志
    (职员)2015-12-04 星期五 周志
    (职员)2015-12-04 星期五 日志
  • 原文地址:https://www.cnblogs.com/haodayikeshu/p/5327454.html
Copyright © 2011-2022 走看看