php比较酷的分页代码
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>
php最简单的文件上传代码
<?php
include("top.txt");
include("scripts.txt");
if(isset($_FILES['ufile']['name'])){
echo "Uploading: ".$_FILES['ufile']['name']."<br>";
$tmpName = $_FILES['ufile']['tmp_name'];
$newName = UPLOADEDFILES . $_FILES['ufile']['name'];
if(!is_uploaded_file($tmpName) || !move_uploaded_file($tmpName, $newName)){
echo "FAILED TO UPLOAD " . $_FILES['ufile']['name'] .
"<br>Temporary Name: $tmpName <br>";
} else {
echo "File uploaded. Thank you!";
}
} else {
echo "You need to select a file. Please try again.";
}
include("bottom.txt");
?>
在论坛里看到很多人碰到将数据插入到数据库的时候显示乱码及从数据库读取出来的数据在网页上显示为乱码的问题,为了能方便用户能在第一时间解决问题,今天特意写了这个教程,希望对有需要的朋友有所帮助。(其实就是做到数据库编码,网页编码及表的编码一致)!GBK2312与下同理
(1) 设置数据库编码, 为了与国际接轨,一般都设置成utf-8
mysql1.gif (16.06 KB)
2007-11-2 13:34
(2)数据表的设置,也设置成utf-8
mysql2.gif (17.23 KB)
2007-11-2 13:34
(3)把你的网页编码也设置成utf-8,打开Dreamweaver,(修改)--(页面属性)
3.gif (7.54 KB)
2007-11-2 13:34
4.gif (18.36 KB)
2007-11-2 13:34
(4)在你的PHP文件的第一行加上 header("Content-Type: text/html; charset=utf-8");
5.gif (1.76 KB)
2007-11-2 13:34
(5)在对数据进行操作之前应该先进行mysql_query('set names utf8');操作,然后再执行对数据的查询,更新,插入等
6.gif (9.49 KB)
2007-11-2 13:34
php数组的灵活应用
function addInput($a)
{
if(is_array($a))
{
$title = $a['title'];
$name = $a['name'];
$value = $a['value'] ? $a['value'] : "";
$type = $a['type'] ? $a['type'] : "text";
$maxlength = $a['maxlength'] ? $a['maxlength'] : "255";
$readonly = $a['readonly'] ? $a['readonly'] : "";
$required = $a['required'] ? $a['required'] : "false";
$check = $a['check'];
$id = $a['id'];
$width = $a['width'];
$tip = $a['tip'];
}
$title,$name,$value="",$type="text",$maxlength="255",$readonly,$required="false",$check,$id,$width,$tip
$this->form .= "<li>\n";
$this->form .= "<label>".$title.":</label>\n";
$this->form .= "<input name=\"".$name."\" value=\"".$value."\" type=\"".$type."\" maxlength=\"".$maxlength."\" required=\"".$required."\" check=\"".$check."\" id=\"".$id."\" class=\"input\" ".$readonly." style=\"width:".$width."px;\" showName=\"".$title."\" /> ";
$this->form .= "<span class=\"tip\">".$tip."</span>\n";
$this->form .= "</li>\n";
}
<?php
if($submit)
{
if($chkme)
{
printf("你选择了CHECKBOX");
}
else
{
printf("你没有选择CHECKBOX");
}
}
else
{
?>
<html>
<head>
<meta charset="GB2312">
<title>测试提交</title>
</head>
<body>
<form action="<?php echo $PATH_INFO ?>" method=post>
<input type=checkbox checked name="chkme">选我
<input type=submit name=submit value="提交">
</form>
</body>
</html>
<?php
}
?>
<html>
<body>
<form action="xxx.php" onsubmit=“if(!document.getElementById('check').checked){alert('请选择!');return false;}”>
<input type="checkbox" id="check">
<input type="submit">
</form>
</body>
</html>
相关文章
- 我们这里介绍php与KindEditor编辑器使用时如何利用KindEditor编辑器的分页功能实现文章内容分页,KindEditor编辑器在我们点击分页时会插入代码,我们只要以它为分切符,就...2016-11-25
- 最近接了一个项目,其中有需求要用到jquery分页控件,上网也找到了需要分页控件,各种写法各种用法,都是很复杂,最终决定自己动手写一个jquery分页控件,全当是练练手了。写的不好,还请见谅,本分页控件在chrome测试过,其他的兼容性...2015-10-30
- 这篇文章主要介绍了源码分析系列之json_encode()如何转化一个对象,对json_encode()感兴趣的同学,可以参考下...2021-04-22
- 有一种方法,可以不打开网站而直接查看到这个网站的源代码.. 这样可以有效地防止误入恶意网站... 在浏览器地址栏输入: view-source:http://...2016-09-20
- PHP去除html、css样式、js格式的方法很多,但发现,它们基本都有一个弊端:空格往往清除不了 经过不断的研究,最终找到了一个理想的去除html包括空格css样式、js 的PHP函数。...2013-08-02
- <?php require('path.inc.php'); header('content-Type: text/html; charset=utf-8'); $borough_id = intval($_GET['id']); if(!$borough_id){ echo ' ...2016-11-25
- 本文实例讲述了JS基于Mootools实现的个性菜单效果代码。分享给大家供大家参考,具体如下:这里演示基于Mootools做的带动画的垂直型菜单,是一个初学者写的,用来学习Mootools的使用有帮助,下载时请注意要将外部引用的mootools...2015-10-23
- 本文实例讲述了JS+CSS实现分类动态选择及移动功能效果代码。分享给大家供大家参考,具体如下:这是一个类似选项卡功能的选择插件,与普通的TAb区别是加入了动画效果,多用于商品类网站,用作商品分类功能,不过其它网站也可以用,...2015-10-21
- 本文实例讲述了JS实现自定义简单网页软键盘效果。分享给大家供大家参考,具体如下:这是一款自定义的简单点的网页软键盘,没有使用任何控件,仅是为了练习JavaScript编写水平,安全性方面没有过多考虑,有顾虑的可以不用,目的是学...2015-11-08
- 本文实例讲述了jquery实现的伪分页效果代码。分享给大家供大家参考,具体如下:这里介绍的jquery伪分页效果,在火狐下表现完美,IE全系列下有些问题,引入了jQuery1.7.2插件,代码里有丰富的注释,相信对学习jQuery有不小的帮助,期...2015-10-30
- php 取除连续空格与换行代码,这些我们都用到str_replace与正则函数 第一种: $content=str_replace("n","",$content); echo $content; 第二种: $content=preg_replac...2016-11-25
- php简单用户登陆程序代码 这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。 <center> <p> </p> <p> </p> <form name="form1...2016-11-25
- 公司一些wordpress网站由于下载的插件存在恶意代码,导致整个服务器所有网站PHP文件都存在恶意代码,就写了个简单的脚本清除。恶意代码示例...2015-10-23
- 本文实例讲述了JS实现双击屏幕滚动效果代码。分享给大家供大家参考,具体如下:这里演示双击滚屏效果代码的实现方法,不知道有觉得有用处的没,现在网上还有很多还在用这个特效的呢,代码分享给大家吧。运行效果截图如下:在线演...2015-10-30
- 其实挺简单的就是if(navigator.userAgent.indexOf('UCBrowser') > -1) {alert("uc浏览器");}else{//不是uc浏览器执行的操作}如果想测试某个浏览器的特征可以通过如下方法获取JS获取浏览器信息 浏览器代码名称:navigator...2015-11-08
- index.php怎么打开?初学者可能不知道如何打开index.php,不会的同学可以参考一下本篇教程 打开编辑:右键->打开方式->经文本方式打开打开运行:首先你要有个支持运行PH...2017-07-06
- 一、日期减去天数等于第二个日期function cc(dd,dadd){//可以加上错误处理var a = new Date(dd)a = a.valueOf()a = a - dadd * 24 * 60 * 60 * 1000a = new Date(a)alert(a.getFullYear() + "年" + (a.getMonth() +...2015-11-08
- 微信支付,即便交了保证金,你还是处理测试阶段,不能正式发布。必须到你通过程序测试提交订单、发货通知等数据到微信的系统中,才能申请发布。然后,因为在微信中是通过JS方式调用API,必须在微信后台设置支付授权目录,而且要到...2014-05-31
- Vue.js通过简洁的API提供高效的数据绑定和灵活的组件系统.这篇文章主要介绍了vue.js 表格分页ajax 异步加载数据的相关资料,需要的朋友可以参考下...2016-10-20
- 本文实例讲述了PHP常用的小程序代码段。分享给大家供大家参考,具体如下:1.计算两个时间的相差几天$startdate=strtotime("2009-12-09");$enddate=strtotime("2009-12-05");上面的php时间日期函数strtotime已经把字符串...2015-11-24