PHP's Cool paging code

Source: Internet
Author: User

function Frendsaction ()
{
$uid =$_get[uid];
$db =&new DataBase ();
$page =isset ($_get[page]) $_get[page]:1;
if ($page <1)
{
$page = 1;
}
$pagerow how many =71;//per page
$sql = "Select A.friendid,b.avatar from Dbo_u2m_friends a inner join Discuz.cdb_memberfields B on A.friendid=b.uid where Mem Berid= ". $uid//calculation of how many
$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\ ">&nbsp;</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."); \ ></div>";
}
Else
{
$div. = "<div class=\" mainbox\ ". $sback." Style=\ "Position:absolute;top:". $y. " Px;left: ". $x." Px;height:99px;width:99px\ ">&nbsp;</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> calling JS
<script language= "JavaScript" >
<!--
var pg = new Showpages (' PG ');
Pg.pagecount ={pagecount}; Define total pages (necessary)
Pg.detail= ' A total of {frendscount} friend ';
pg.argname = ' P '; Define parameter names (optional, default is page)
document.write (' <br>show times: ' + Pg.showtimes + ', Mood 2 ');
document.write (' 1 ');
Pg.printhtml (2);
-->
</script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.