function frendsAction()
{
$uid=$_GET[uid];
$db=&new DataBase();
$page=isset($_GET[page])?$_GET[page]:1;
if($page<1)
{
$page=1;
}
$pagerow=71;//每頁顯示多少條
$sql="select a.FriendID,b.avatar from dbo_u2m_friends a inner join discuz.cdb_memberfields b on a.FriendID=b.uid where MemberID=".$uid;//計算有多少條
$getPage=&new page($db);
$getPage->getPage($page,$pagerow,$sql);
$rows=$getPage->AllRow;
$t = new Template("views/User");
$t->set_file("index","frendsindex.lhtml");
$t->set_file("header","header.lhtml");
$t->set_file("footer","footer.lhtml");
$t->set_var(array('uid'=>$uid));
$t->parse("header","header");
$t->parse("footer","footer");
$div="";
$n=0;
for($i=1;$i<=8;$i++)
{
for($j=1;$j<=9;$j++)
{
$x=($j-1)*99+58;
$y=($i-1)*99+62;
if($i==1&&$j==1)
{
$div.="<div class=\"FriendsNav\" style=\"position:absolute;top:".$y."px;left:".$x."px;height:99px;width:99px\"></div>";
}
else
{
if($_COOKIE['user']['userid']==$uid)
{
$sback="onmouseover=\"ShowBackground('addactive',this)\"";
}
else
{
$sback="";
}
if($i==8&&$j==9)
{
$div.="<div class=\"Mainbox\" ".$sback." style=\"position:absolute;top:".$y."px;left:".$x."px;height:99px;width:99px\"> </div>";
}
else
{
if(isset($rows)&&$n<=count($rows))
{
$div.="<div id=\"".$rows[$n-1][FriendID]."\" onclick=\"javascript:window.location='?controller=user&uid=".$rows[$n-1][FriendID]."'\" class=\"ActivitiesItem\" style=\"position:absolute;top:".$y."px;left:".$x."px;height:99px;width:99px;background:url(".$rows[$n-1][avatar].") center no-repeat;cursorointer\" onmouseover=\"ShowDiv('FriendsInfo','".$i.$j."',this);\" onmouseout=\"HideDiv('FriendsInfo','".$i.$j."');\" ><img id=\"".$i.$j."\" src=\"views/user/images/bg/Friends_view.gif\" border=\"0\"/></div>";
}
else
{
$div.="<div class=\"Mainbox\" ".$sback." style=\"position:absolute;top:".$y."px;left:".$x."px;height:99px;width:99px\"> </div>";
}
}
}
$n++;
}
}
$t->set_var(array("pageCount"=>$getPage->PageCount,"FrendsCount"=>$getPage->RowCount,"divshow"=>$div,"uid"=>$uid));
$t->parse("out","index");
$t->p("out");
}
<script type="text/javascript" src="views/scripts/page.js"></script>調用js
<script language="JavaScript">
<!--
var pg = new showPages('pg');
pg.pageCount ={pageCount}; // 定義總頁數(必要)
pg.detail='共有{FrendsCount}位好友';
//pg.argName = 'p'; // 定義參數名(可選,默認為page)
//document.write('<br>Show Times: ' + pg.showTimes + ', Mood 2');
//document.write('1');
pg.printHtml(2);
//-->
</script>