zoukankan      html  css  js  c++  java
  • php 练习一 5月5日

    练习题一:通过登录者找到他的好友并显示在页面上

    <title>无标题文档</title>
    <style type="text/css">
    *
    {
    	margin:0px auto;
    	padding:0px;
    	}
    .hy
    {
    	200px;
    	height:50px;
    	margin-top:5px;
    	}
    .hy.hover
    {
    	background:#9CF;
    	cursor:pointer;
    	color:#FFF;}
    .pic
    {
    	50px;
    	height:50px;
    	float:left;
    	}
    .nk
    {
    	120px;
    	height:50px;
    	line-height:50px;
    	vertical-align:middle;
    	margin-left:30px;
    	float:left;
    	}
    
    </style>
    
    </head>
    
    <body>
    <?php
    $uid="18653378660";
    ?>
    
    <?php
    $db=new MySQLi("localhost","root","","weixin");
    !mysqli_connect_error() or die("连接失败!");
    $sql="select Friends from friends where Uid='{$uid}'";
    $result=$db->query($sql);
    $arr=$result->fetch_all();
    //循环读取好友的用户名
    foreach ($arr as $v)
    {
    	$fuid=$v[0];//好友的用户名
    	//根据好友的用户名在users表中查询出他的昵称和头像
    	$sqln="select NickName, Pic from users where Uid='{$fuid}'";
    	$resultn=$db->query($sqln);
    	$att=$resultn->fetch_row();
    	//输出头像$att[1]和昵称$att[0]
    	echo "<div class='hy' onclick='Select(this)'>
    	<div class='pic'><img src='{$att[1]}' width='50' height='50'/></div> 
    	<div class='nk'><img src='{$att[0]}'/></div>
    	<div>";
    	
    	}
    ?>
    
    </body>
    
    <script type="text/javascript">
    function Select(a)
    {
    	//清除所有选中的状态:
    	var div=document.getElementsByClassName("hy");
    	for(var i=0;i<div.length;i++)
    	{
    		div[i].style.backgroundColor="#FFF";
    		div[i].style.color="#000";
    		}
    	
    	//设置选中时的状态:
    	a.style.backgroundColor="#9CF";
    	a.style.color="#FFF";
    	}
    
    </script>
    

      

    附:以前没学好的一点内容:float

    <style>

    .a
    {
    200px;
    height:50px;
    float:left;}


    </style>

    </head>

    <body>
    <div class="a">aa</div>
    <div class="a">bb</div>
    <div class="a">cc</div>
    <div class="a">dd</div>
    <div class="a">ee</div>
    <div class="a">ff</div>

    <div style="background:#60F; 400px; height:100px;">ww</div>

    </body> 

    如何截断流:<div style="clear:both"></div>

    <body>
    <div class="a">aa</div>
    <div class="a">bb</div>
    <div class="a">cc</div>
    <div class="a">dd</div>
    <div class="a">ee</div>
    <div class="a">ff</div>
    <div style="clear:both"></div> <!--截断流-->

    <div style="background:#60F; 400px; height:100px;">ww</div>

  • 相关阅读:
    linux常用命令
    linux简介
    vmware+CentOs 6.9的安装步骤
    Android layer type与WebView白屏-第一次加载webview很慢
    Android View框架的measure机制
    maven的facet错误解决方法
    oracle jdbc驱动发布nexus
    dubbox2.8.4编译发布到私服(nexus)
    一致性哈希 与 普通哈希对比
    1对多业务,数据库水平切分架构一次搞定 | 架构师之路
  • 原文地址:https://www.cnblogs.com/ds-3579/p/5461099.html
Copyright © 2011-2022 走看看