php+ajax分页代码
<html>
<head>
<script language="javascript">
function createXMLHttp(){
if(window.ActiveXObject){
return new ActiveXObject("Microsoft.XMLHttp");
}
else if(window.XMLHttpRequest){
return new XMLHttpRequest();
}
}
function Pager(){
var that=this;
this.link=function(url){
that.xmlHttp = createXMLHttp();
that.xmlHttp.onreadystatechange = that.receive;
that.xmlHttp.open("GET", url, true);
that.xmlHttp.send(null);
}
this.receive=function(){
if((that.xmlHttp.readyState == 4)){
if(that.xmlHttp.status == 200){
that.reaction(that.xmlHttp.responseXML);
}else{
that.recover();
}
}
}
}
</script>
</head>
<body>
<div id='page_content'></div>
<div id='page_bar'></div>
<script language="javascript">
var a = new Pager();
var pages = 0;
a.recover = function (){
go = function (u){
go = function (){
};
a.link(u);
};
};
a.reaction = function (xml){
document.getElementById('page_content').innerHTML = xml.getElementsByTagName('content')[0].childNodes[0].nodeValue;
if(xml.getElementsByTagName('count')[0].childNodes[0].nodeValue != pages){
s = '<table><tr>';
for(i = 1; i <= xml.getElementsByTagName('count')[0].childNodes[0].nodeValue; i++)
{
if(i == xml.getElementsByTagName('current')[0].childNodes[0].nodeValue)
s += '<td><b>' + i + '</b></td>';
else
s += '<td><a href="javascript:go(\'page.php?page=' + i + '\')">' + i + '</a></td>';
}
s += '</tr></table>';
document.getElementById('page_bar').innerHTML = s;
}
a.recover();
}
a.link('page.php');
</script>
</body>
</html>
page.php代码.
<?php
class class_page
{
private $record_count, $perpage;
private $page_count, $page_current;
function __construct($perpage, $record_count, $page_current)
{
$this->perpage = $perpage;
$this->record_count = $record_count;
$this->page_count = ($record_count == 0) ? 1 : ceil($record_count / $perpage);
$this->page_current = ($page_current > $this->page_count) ? 1 : $page_current;
}
function __get($name)
{
switch($name)
{
case 'page_count':
return $this->page_count;
case 'page_current':
return $this->page_current;
case 'record_start':
return ($this->page_current - 1) * $this->perpage;
}
}
}
header('Content-Type: text/xml; charset=gbk');
$page = new class_page(20, 150, is_numeric($_GET['page']) ? $_GET['page'] : 1);
echo '<?xml version="1.0"?>';
echo '<page>';
echo '<count>' . $page->page_count . '</count>';
echo '<current>' . $page->page_current . '</current>';
echo '<content>' . pow($page->page_current, 2) . '</content>';
echo '</page>';
?>
php把ubb代码转换成html
function ubb($Text)
{
$Text=htmlspecialchars($Text);
$Text=stripslashes($Text);
$Text=ereg_replace("\r\n","<br/>",$Text);
$Text=ereg_replace("\r","<br/>",$Text);
$Text=nl2br($Text);
$Text=preg_replace("/\\t/is"," ",$Text);
$Text=ereg_replace(" "," ",$Text);
$Text=preg_replace("/\[h1\](.+?)\[\/h1\]/is","<h1>\\1</h1>",$Text);
$Text=preg_replace("/\[h2\](.+?)\[\/h2\]/is","<h2>\\1</h2>",$Text);
$Text=preg_replace("/\[h3\](.+?)\[\/h3\]/is","<h3>\\1</h3>",$Text);
$Text=preg_replace("/\[h4\](.+?)\[\/h4\]/is","<h4>\\1</h4>",$Text);
$Text=preg_replace("/\[h5\](.+?)\[\/h5\]/is","<h5>\\1</h5>",$Text);
$Text=preg_replace("/\[h6\](.+?)\[\/h6\]/is","<h6>\\1</h6>",$Text);
$Text=preg_replace("/\[center\](.+?)\[\/center\]/is","<center>\\1</center>",$Text);
$Text=preg_replace("/\[big\](.+?)\[\/big\]/is","<big>\\1</big>",$Text);
$Text=preg_replace("/\[small\](.+?)\[\/small\]/is","<small>\\1</small>",$Text);
$Text=preg_replace("/\[url\](http:\/\/.+?)\[\/url\]/is","<a href=\\1>\\1</a>",$Text);
$Text=preg_replace("/\[url\](.+?)\[\/url\]/is","<a href=\'http://\\1\'>http://\\1</a>",$Text);
$Text=preg_replace("/\[url=(http:\/\/.+?)\](.*)\[\/url\]/is","<a href=\\1>\\2</a>",$Text);
$Text=preg_replace("/\[url=(.+?)\](.*)\[\/url\]/is","<a href=http://\\1>\\2</a>",$Text);
$Text=preg_replace("/\[img\](.+?)\[\/img\]/is","<img src=\\1 border=0>",$Text);
$Text=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/is","<font color=\\1>\\2</font>",$Text);
$Text=preg_replace("/\[size=(.+?)\](.+?)\[\/size\]/is","<font size=\\1>\\2</font>",$Text);
$Text=preg_replace("/\[sup\](.+?)\[\/sup\]/is","<sup>\\1</sup>",$Text);
$Text=preg_replace("/\[sub\](.+?)\[\/sub\]/is","<sub>\\1</sub>",$Text);
$Text=preg_replace("/\[pre\](.+?)\[\/pre\]/is","<pre>\\1</pre>",$Text);
$Text=preg_replace("/\[email\](.+?)\[\/email\]/is","<a href=mailto:\\1>\\1</a>",$Text);
$Text=preg_replace("/\[i\](.+?)\[\/i\]/is","<i>\\1</i>",$Text);
$Text=preg_replace("/\[b\](.+?)\[\/b\]/is","<b>\\1</b>",$Text);
$Text=preg_replace("/\[quote\](.+?)\[\/quote\]/is","<blockquote><font size='1' face='Courier New'>quote:</font><hr>\\1<hr></blockquote>", $Text);
$pattern = "/(\[uploadimage\])(\d+),(.*)(\[\/uploadimage\])/U";
$replacement = "<img src=\"\$3\" \>";
$Text =@preg_replace($pattern, $replacement, $Text);
$str = $Text;
$pattern='#\[flash=(\d+),(\d+)\](.+)\[/flash\]#';
$last = "<center><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"$2\" height=\"291\">
<param name=\"movie\" value=\"$3\" /><param name=\"quality\" value=\"high\" /><embed src=\"$3\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"
width=\"$2\" height=\"$1\"></embed></object><br>
<a href=\"$3\" >[全屏欣赏 提醒:Flash中可能包含不安全内容]</a>
</center>";
$Text= preg_replace($pattern, $last, $str);
$mpg ="<center>
<object align=\"middle\" classid=\"clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" class=\"object\" id=\"mediaplayer\" width=\"$2\" height=\"290\">
<param name=\"showstatusbar\" value=\"-1\" />
<param name=\"filename\" value=\"$3\" />
<embed type=\"application/x-oleobject\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=5,1,52,701\" filename=\"hong\" src=\"$3\" width=\"$2\" height=\"$1\">
</embed>
</object>
</center>";
$Text =preg_replace('#\[mp=(\d+),(\d+)\](.+)\[/mp\]#', $mpg, $Text);
return @iconv('utf-8','gbk',@iconv('gbk','utf-8',$Text));
}
创建文件夹
代码如下 | 复制代码 |
function Createfolder($path,$nname){ if(preg_match("/^\w{1,255}$/i",$nname)){ }else{ } |
粘贴文件
function Past($currentpath,$currentfilename,$filepote){ //1:文件要被粘贴到的位置2:当前文件{夹}名3:文件{夹}所在的物理地址
$str = substr($currentfilename,-1,1);
if(substr($currentfilename,-1,1)=="|"){
www.111cn.net
$currentfilename = str_replace("|","",$currentfilename);
$filepote = str_replace("|","",$filepote);
}www.111cn.net
if(is_dir($currentpath) && is_writable($currentpath) && is_dir($filepote) && is_writable($filepote)){
www.111cn.net
//@mkdir($currentpath."/".$currentfilename);
$t=full_copy($filepote,$currentpath."/".$currentfilename)?'t':'f';//$filepote,need copy folder $current sava folder
www.111cn.net
}else if(is_file($filepote) && file_exists($filepote)){
if(file_exists($currentpath.$currentfilename)){ echo ('file exists! plase rename it!');exit;}
echo copy($filepote,$currentpath.$currentfilename)?'success':'errror';
www.111cn.net
}
if( $str =="|" && $t='t' ){
deldir($filepote);
www.111cn.net
}
}
原创文章:转载请注明www.111cn.net
代码如下 | 复制代码 |
<?php if(move_uploaded_file($_FILES['file']['tmp_name'],$uploadsava)){ ?> |
原创文章 载注明: www.111cn.net
php explode 函数的用法,这是我自家用的explode的用法
if( !empty($ct) ){
if(strpos($ct,"|")===false){
mysql_query($sql) or die(mysql_error());
exit("<script>alert('insert success!');location='add_type.php';</script>");
}else{
$ex=explode("|",$ct);
for($i=0;$i<sizeof($ex);$i++){
$r=mysql_query("select * from ffff where zddd='".$ex[$i]."'") ;
if(!mysql_fetch_array($r)){
mysql_query("insert into rwerew(f_idfff,z_time) value($zm,'".$ex[$i]."','".date("Y-m-d")."')") or die(mysql_error());
}
}
exit("<script>alert('insert success!');location='add_type.php';</script>");
}
}else{
exit("<script>alert('info Error!');history.back();</script>");
}
原创文章转载请注明:www.111cn.net
相关文章
- 我们这里介绍php与KindEditor编辑器使用时如何利用KindEditor编辑器的分页功能实现文章内容分页,KindEditor编辑器在我们点击分页时会插入代码,我们只要以它为分切符,就...2016-11-25
- 最近接了一个项目,其中有需求要用到jquery分页控件,上网也找到了需要分页控件,各种写法各种用法,都是很复杂,最终决定自己动手写一个jquery分页控件,全当是练练手了。写的不好,还请见谅,本分页控件在chrome测试过,其他的兼容性...2015-10-30
- 有一种方法,可以不打开网站而直接查看到这个网站的源代码.. 这样可以有效地防止误入恶意网站... 在浏览器地址栏输入: view-source:http://...2016-09-20
- <?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
- 其实挺简单的就是if(navigator.userAgent.indexOf('UCBrowser') > -1) {alert("uc浏览器");}else{//不是uc浏览器执行的操作}如果想测试某个浏览器的特征可以通过如下方法获取JS获取浏览器信息 浏览器代码名称:navigator...2015-11-08
- 本文实例讲述了JS实现双击屏幕滚动效果代码。分享给大家供大家参考,具体如下:这里演示双击滚屏效果代码的实现方法,不知道有觉得有用处的没,现在网上还有很多还在用这个特效的呢,代码分享给大家吧。运行效果截图如下:在线演...2015-10-30
- 一、日期减去天数等于第二个日期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
- 小编分享了一段简单的php中文转拼音的实现代码,代码简单易懂,适合初学php的同学参考学习。 代码如下 复制代码 <?phpfunction Pinyin($_String...2017-07-06
php导出csv格式数据并将数字转换成文本的思路以及代码分享
php导出csv格式数据实现:先定义一个字符串 存储内容,例如 $exportdata = '规则111,规则222,审222,规222,服2222,规则1,规则2,规则3,匹配字符,设置时间,有效期'."/n";然后对需要保存csv的数组进行foreach循环,例如复制代...2014-06-07- ecshop商品无限级分类代码 function cat_options($spec_cat_id, $arr) { static $cat_options = array(); if (isset($cat_options[$spec_cat_id]))...2016-11-25