練習資料庫和網頁布局(查詢好友名單)

來源:互聯網
上載者:User

標籤:

學習:查詢好友名單

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>練習資料庫與網頁布局</title><style>*{marger:0px auto;padding:0px;}.hy{width:200px;height:50px;margin-top:5px;}/*   //使用下邊的js之後,這些就不用了.hy:hover{background-color:#999;cursor:pointer;}*/.pic{width:50;height:50px;float:left;}.nk{height:50px;width:130px;float:left;margin-left:20px;line-height:50px;vertical-align:middle;}</style></head><body><?php$uid="18653378660";?><?php$db=new MySQLi("localhost","root","","mydb");$sql="select friends from friends where uid=‘18653378660‘";$result = $db->query($sql);$attr=$result->fetch_all();foreach($attr as $v){$fuid=$v[0];//好友的使用者名稱//根據使用者名稱查詢users表的暱稱和頭像$sqlu="select nickname pic from users where uid=‘{$fuid}‘";$r=$db->query($sqlu);$attr=$r->fetch_row();echo "<div class=‘hy‘ onclick=‘select(this)‘>          <div class=‘pic‘><img width=‘50px‘ height=‘50px‘ src=‘{$attr[1]}‘/></div>  <div class=‘nk‘>{$attr[0]}</div>      </div>";}?></body><script type="text/javascript">function select(aa)  //aa代表該div{//清除原選中狀態var div=document.getElementsByClassName("hy");for(var i=0;i<div.length;i++){div[i].style.backgroundColor="white";div[i].style.color="#000000";}//設定選中aa.style.bachgroundcolor="#60c";aa.style.color="while";}</script></html>

  

練習資料庫和網頁布局(查詢好友名單)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.