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 width: 350px;height: 400px; 16 } 17 .py 18 { margin:8px 0px 0px 0px; 19 width:350px; height: 35px; 20 } 21 .py:hover /*鼠标点击时变色*/ 22 { 23 background-color:#639; 24 color:#FFF; 25 cursor:pointer;/*鼠标变成手*/ 26 } 27 .img 28 { 29 width: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>
时间: 2024-10-08 09:48:10