php通用分页类代码

 更新时间:2016年11月25日 16:39  点击:2230

 

 代码如下 复制代码

class dividepage{//分页类
 private $total;//要显示的总记录数
 private $url;//请求的url地址
 private $displaypg;//每页显示的记录数,默认为每页显示10条记录
 private $page;//当前页码
 private $lastpg;//总页数,即最后一页的页码
 private $prepg;//前一页
 private $nextpg;//后一页
 private $firstcount;//记录条数开始的序号从0开始
 private $startd;//记录条数开始的记录号.
 private $stopd;//记录条数结束的记录号.

//构造函数
public function __construct($url, $total, $displaypg){
 $this->url = $url;//请求的url
 $this->total = $total;//总记录数
 //if($displaypg == '')
 $this->displaypg = $displaypg;//每页显示的记录数
 $this->initdividepage();//初始化分页类
 //echo ','.$this->displaypg;
}

//初始化分页类
private function initdividepage(){
 //分析url
 $parse_url = parse_url($this->url);//将url解释为有固定键值对的数组
 $url_query = $parse_url['query'];//取出url中的查询字符串
 if($url_query){//如果有查询字符串,则删除查询字串中当前页的查询字段如:&page=$page或page=$page
  ereg('(^|&)page=([0-9]*)', $url_query, $k);
  $this->page = $k[2];//取得当前页的值
  $url_query = ereg_replace("(^|&)page=$this->page", '', $url_query);//删除查询字串中当前页的查询字段如:&page=$page或page=$page
  $this->url = str_replace($parse_url['query'], $url_query, $this->url);//保留其他的查询字串,
  $this->page = $this->page ? $this->page : 1;//w如果查询字符串中没有当前页的值就设当前页为1
  if($url_query){//如果有其他查询字符串,则以&page=$page形式添加翻页查询字串
   $this->url .= '&page';
  }else{//如果没有其他查询字串,则以page=$page形式添加翻页查询字串
   $this->url .= 'page';
  }
 }else{//如果没有查询字串,则在url后添加?page=$page形式的翻页查询字串
  $this->page = 1;
  $this->url .= '?page';
 }
 $this->lastpg = ceil($this->total / $this->displaypg);//计算总页数,即最后一页的页码
    $this->page = min($this->lastpg, $this->page);//如果当前页大于总页数,则当前页为最后一页的页码
    $this->prepg = $this->page - 1;//上一页为当前页减一www.111cn.net
    $this->nextpg = $this->page + 1;//(($this->page == $this->lastpg) ? $this->lastpg : ($this->page + 1));//下一页为当前页加一,如果当前页为最后一页,则下一页为0
    $this->firstcount = ($this->page - 1) * $this->displaypg;//计算当前页,记录条数开始的记录号,从0开始.
 $this->startd = $this->total ? ($this->firstcount + 1) : 0;//记录开始号从1开始
 $this->stopd = min($this->firstcount + $this->displaypg, $this->total);//记录结束号
 //echo $this->displaypg;
 //echo $this->nextpg.'+=+='.$this->lastpg;
}

public function getpageinfo(){//取得当前页面的基本信息,如:显示第 1-10 条记录,共 23 条记录。
 return '<span class="pageinfostyle">显示第<span class="numstyle">'.$this->startd.'-'.$this->stopd.'</span>条记录,共<span class="numstyle">'.$this->total.'</span>条记录。</span>';
}

public function getcommonpagenav(){//取得通常的分页导航,如:首页 上一页 下一页 尾页
 $commonnav = '';
 if($this->lastpg == 1){//如果只有一页,则返回翻页导航,退出,不显示下一页,上一页等。。。
  return $commonnav;
  break;
 }
 $commonnav = '<a href="'.$this->url.'=1" class="compagestyle">首页</a>';//设置首页导航,page=1
 if($this->prepg){
  $commonnav .= '<a href="'.$this->url.'='.$this->prepg.'" class="compagestyle">上一页</a>';
 }else{
  $commonnav .= '<a class="fcompagestyle">上一页</a>';
 }
 if($this->nextpg <= $this->lastpg){
  $commonnav .= '<a href="'.$this->url.'='.$this->nextpg.'" class="compagestyle">下一页</a>';
 }else{
  $commonnav .= '<a class="fcompagestyle">下一页</a>';
 }
 $commonnav .= '<a href="'.$this->url.'='.$this->lastpg.'" class="compagestyle">尾页</a>';//显示尾页链接
 return $commonnav;
}

//取得跳转分页导航,如:第n页
public function getjumppagenav(){
 //<select name='topage' size='1' onchange='window.location="/test/page.php?page="+this.value'>
 $jumpnav = '<span class="pageinfostyle">到第<select name="topage" size="1" class="topage"  onchange='window.location="'.$this->url.'="+this.value'>'." ";
 for($i = 1; $i <= $this->lastpg; $i++){
  if($i == $this->page){//把当前页的页码作为默认选项
   $jumpnav .= '<option value="'.$i.'" selected>'.$i.'</option>'." ";
  }else{
   $jumpnav .= '<option value="'.$i.'">'.$i.'</option>'." ";
  }
 }
 $jumpnav .= '</select>页,共<span class="numstyle">'.$this->lastpg.'</span>页</span>';
 return $jumpnav;
}

//取得所有的分页导航
public function getallpagenav(){
 $temp =  $this->getpageinfo().$this->getcommonpagenav().$this->getjumppagenav();
 return $temp;
}

//取得当前页需显示的记录,在数据库教程中的限定范围,如0-9
public function getlimitstr(){
 //echo $this->page;
 //echo $this->firstcount;
 
 //echo $this->dispalypg;
 $temp = $this->firstcount.','.$this->displaypg;
 //echo $temp;
 return $temp;
}

}

 

/*
使用实例:

 代码如下 复制代码
*$result=mysql教程_query("select * from tb_pagetest");//从数据库中查询所需显示的数据
*$total=mysql_num_rows($result);//查询到的数据的总条数
*$pagesize = 5;//每页显示的记录条数
*$url = $_server['request_uri'];//请求的uri
*
*$dividepageclass = new dividepage($url, $total, $pagesize); //创建分页类,(类能自动初始化)
*$limitstr = $dividepageclass->getlimitstr();//取得当前页要显示的记录开始序号和每页显示条数,如:0, 5(显示从0开始的5条记录)
*echo $dividepageclass->getallpagenav();//显示所有分页导航条,
*如:显示第11-13条记录,共13条记录。首页 上一页 下一页 尾页 到*第 1 页,共 3 页
*$sql = 'select * from tb_pagetest limit '.$limitstr;
*$result=mysql_query($sql);//从数据库中取得当前页要显示的记录集,然后显示就ok
*如:
*while($row=mysql_fetch_array($result))
*echo "<hr><b>".$row[title]." | ".$row[author];

 

 

这是一款比较适合php初学者学的教程哦,我们利用一个简单的实例来对数据库添加、修改、删除哦,这样更系统的让各位知道php mysql数据库操作的要点。

  require_once('common.php');
  $action = $_get['action'];
?>

 代码如下 复制代码

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>人才列表</title>
<link href="style.css教程" type="text/css" rel="stylesheet" />
</head>
<body> 
 <div id="wrap">
 <div id="main">
 <?php
      if($action=='add'){
 ?>
    <form action="?action=save" method="post" name="form1">
  <table width="300" border="0" cellspacing="0" cellpadding="0"  class="post">
          <tr>
            <td colspan="2">添加人员</td></tr>
          <tr><td width="78">登陆账号</td>
            <td width="220"><input name="login" type="text" id="login" /></td>
          </tr>
          <tr>
            <td>登陆密码</td>
            <td><input name="pws" type="text" id="pws" /></td>
          </tr>
          <tr>
            <td>问题</td>
            <td><input name="question" type="text" id="question" /></td>
          </tr>
           <tr>
            <td>答案</td>
            <td><input name="answer" type="text" id="answer" /></td>
          </tr>
            <tr>
              <td colspan="2"><input name="button" type="submit" id="button" value=" 添加 " /></td>
            </tr>
             
      </table>
    </form>
 <?php  
      }
      elseif($action=='save'){
    $login = isset($_post['login']) ? $_post['login'] : '';
    $pws = isset($_post['pws']) ? $_post['pws'] : '';
    $question = isset($_post['question']) ? $_post['question'] : '';
    $answer = isset($_post['answer']) ? $_post['answer'] : '';
    $sql = "insert into person (login,pws,question,answer)
    values('$login','$pws','$question','$answer')";
    $db->query($sql);
    forward('发布成功','href','personlist.php');
          }

    elseif($action=='del'){
    $person_id=$_get['person_id'];
    $page=$_get['page'];
    $sql="delete from person where person_id='$person_id'";
    $db->query($sql);
    forward('删除成功','href','personlist.php?page='.$page);
          } 
    elseif($action=='editsave'){
    $person_id = isset($_post['person_id']) ? $_post['person_id'] : '';
    $page = isset($_post['page']) ? $_post['page'] : '';
          $login = isset($_post['login']) ? $_post['login'] : '';
    $pws = isset($_post['pws']) ? $_post['pws'] : '';
    $question = isset($_post['question']) ? $_post['question'] : '';
    $answer = isset($_post['answer']) ? $_post['answer'] : '';
    $sql="update person set login='$login',pws='$pws',question='$question',answer='$answer' where person_id='$person_id'";
    $db->query($sql);
          forward('修改成功','href','personlist.php?page='.$page);
          }
   elseif($action=='edit'){
    $person_id=$_get['person_id'];
    $page=$_get['page'];
    $sql="select * from person where person_id='$person_id'";
    $query = $db->query($sql);
    $row = $db->fetch_array($query);
    $login=$row['login'];
    $pws=$row['pws'];
    $question=$row['question'];
    $answer=$row['answer'];
       ?>
    <form action="?action=editsave" method="post" name="form1">
  <table width="300" border="0" cellspacing="0" cellpadding="0"  class="post">
          <tr>
          <input name="page" type="hidden"  value="<?php echo $page?>"/>
          <input name="person_id" type="hidden"  value="<?php echo $person_id?>"/>
            <td colspan="2">修改人员</td></tr>
          <tr><td width="78">登陆账号</td>
            <td width="220"><input name="login" type="text" id="login"  value="<?php echo $login?>"/></td>
          </tr>
          <tr>
            <td>登陆密码</td>
            <td><input name="pws" type="text" id="pws" value="<?php echo $pws?>"/></td>
          </tr>
          <tr>
            <td>问题</td>
            <td><input name="question" type="text" id="question" value="<?php echo $question?>"/></td>
          </tr>
           <tr>
            <td>答案</td>
            <td><input name="answer" type="text" id="answer" value="<?php echo $answer?>"/></td>
          </tr>
            <tr>
              <td colspan="2"><input name="button" type="submit" id="button" value=" 修改 " /></td>
            </tr>
             
      </table>
    </form>
 <?php 
          }
      else{
          $page = isset($_get['page']) ?intval($_get['page']) : 1;
          $num = 5;
          $sql="select * from person";
          $query = $db->query($sql);
          $totalnum = $db->num_rows($query);//记录总数
          $pagenum = ceil($totalnum/$num); //总页数
          $offset = ($page-1) * $num;
          $sql=$sql." limit $offset,$num ";
          $query = $db->query($sql);//取得记录
        ?>
          <table width="639" border="0" cellspacing="0" cellpadding="0"  class="post">
          <tr>
            <td colspan="6">记录总数:<?php echo $totalnum;?>————<a href="personlist.php?action=add">添加人员</a></td></tr>
          <tr><td width="126">登陆账号</td>
          <td width="98">登陆密码</td>
          <td width="115">问题</td>
          <td width="66">答案</td>
          <td width="138">加入时间</td>
          <td width="94">操作</td>
          </tr>
  <?php
        while ($row = $db->fetch_array($query)) {
        ?>
          <tr>
          <td><?php echo $row['login'];?></td>
            <td><?php echo $row['pws'];?></td>
            <td><?php echo $row['question'];?></td>
            <td><?php echo $row['answer'];?></td>
            <td><?php echo $row['addtime'];?></td>
            <td><a href="?action=del&person_id=<?php echo $row['person_id'] ?>&page=<?php echo $page ?>">删除</a>/
            <a href="?action=edit&person_id=<?php echo $row['person_id'] ?>&page=<?php echo $page ?>">修改</a></td>
          </tr>
       <?php
          }
        ?>
    </table>
   </div>
       <div id="pages_btns">
            <div class="pages"><?php showpage($page, $num, $pagenum, $totalnum)?></div>
   </div>
   <?php
   }
   ?>
</div>
</body>
</html>

 

这是一款简单的php留言板程序代码,如果你正学习网站开发,这款留言板源码可以帮助哦,希望本文章对你有帮助。

 代码如下 复制代码

<!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=gbk" />
<title>所有留言</title>
<link rel="stylesheet" type="text/css教程" href="style.css" media="all" />
</head>

<body>
<a href="add.php">发表留言</a>
<?php
require('common.php');
$result = mysql教程_query("select * from gb_content order by id desc");//查询数据

while ($row = mysql_fetch_array($result, mysql_both)) {// 取一条数据
?>
<table width="700" border="0" cellspacing="0" cellpadding="0" class="tb">
  <tr>
    <td class="bg"><b>[<?php echo htmlentities($row['username'],ent_compat,'utf-8') ?>]</b> 发表于:<?php echo htmlentities($row['insert_time'],ent_compat,'utf-8') ?></td>
  </tr>
  <tr>
    <td><?php echo htmlentities($row['content'],ent_compat,'utf-8') ?></td>
  </tr>
  <tr>
    <td align="right"><a href="edit.php?id=<?php echo $row['id'] ?>">修改</a> <a href="delete.php?id=<?php echo $row['id'] ?>">删除</a></td>
  </tr>
</table>
<?php
}

mysql_free_result($result);

?>
</body>
</html>

 

 代码如下 复制代码

$pg=@pg_connect("host=localhost user=postgres password=sa dbname=employes")
or die("can't connect to database.");
$query="select * from employes order by serial_no";

//$query="insert into employes values(10008,'susan','1985-09-04','80','50')";
$result=@pg_query($pg,$query) or die("can't run query to table.");
//echo pg_num_rows($result); //输出多少条记录被查询
//if($result)
//{
//echo "recrods inserted sucessfully!";
//echo pg_affected_rows($result);//输出多少条记录被插入
//}

//实例一[pg_fetch_row]
echo "<table border=1>";
echo "<tr>";
echo "<td>serial_no</td>";
echo"<td>name</td>";
echo"<td>birthday</td>";
echo"</tr>";

for($i=0;$i<pg_num_rows($result);$i++)
{

$row=@pg_fetch_row($result) or die("can't fetch row from table.");
$serial_no= $row[0];
$name= $row[1];
$birthday= $row[2];
echo"<tr>";
echo"<td>$serial_no</td>";
echo"<td>$name</td>";
echo"<td>$birthday</td>";
echo"</tr>";

}
echo"</table>";

//实例二[pg_fetch_array]
//echo "<table border=1>";
//echo "<tr>";
//echo "<td>serial_no</td>";
//echo"<td>name</td>";
//echo"<td>birthday</td>";
//echo"</tr>";
//
//for($i=0;$i<pg_num_rows($result);$i++)
//{
//
//$row=@pg_fetch_array($result) or die("can't fetch row from table.");
//$serial_no= $row['serial_no'];
//$name= $row['name'];
//$birthday= $row['birthday'];
//echo"<tr>";
//echo"<td>$serial_no</td>";
//echo"<td>$name</td>";
//echo"<td>$birthday</td>";
//echo"</tr>";
//
//}
//echo"</table>";

//增加,删除,修改实例
//$newrow=array("serial_no"=>"1006","name"=>"peter","birthday"=>"1990-07-03","salary"=>"90","bonus"=>"80");
//$reusult=@pg_insert($pg,"employes",$newrow) or die("can't insert data to table.");
//if($reusult)
//{
//echo "rechords inserted sucessfully!";
//}
//
pg_close($pg);

本款php连接mysql数据库连接程序代码是一款比较简单实用的连接代码,希望本教程对各位同学会有所帮助哦。
 代码如下 复制代码

class mysql {
      public $sqlserver = 'localhost';
      public $sqluser = 'root';
      public $sqlpassword = '';
      public $database;

      public $last_query = '';

      private $connection;
      private $query_result;

      public function __construct() {}

      public function __destruct() {
       $this->close();
      }

    //+======================================================+
    // create a connection to the mysql database
    //+======================================================+
    public function connect($server = null, $user = null, $password = null, $database = null){
     if (isset($server)) $this->sqlserver = $server;
     if (isset($user)) $this->sqluser = $user;
     if (isset($password)) $this->sqlpassword = $password;
     if (isset($database)) $this->database = $database;

    $this->connection = mysql_connect($this->sqlserver, $this->sqluser, $this->sqlpassword);
    if($this->connection){
    if (mysql_select_db($this->database)){
    return $this->connection;
    }else{
    return $this->error();
    }
    }else{
    return $this->error();
    }
    }
    //+======================================================+
    // execute a query
    //+======================================================+
    public function query($query, $die = false){
      if ($query != null){
       $this->last_query = $query;
       $this->query_result = mysql_query($query, $this->connection);
       if(!$this->query_result){
        if ($die) die("die: ".$this->query_result);
        return $this->error();
       }else{
        if ($die) die("die: ".$this->query_result);
        return $this->query_result;
       }
      }else{
       echo "empty query cannot be executed!";
      }
    }
    //+======================================================+
    // returns the result
    //+======================================================+
    public function getresult(){
       return $this->query_result;
    }
    //+======================================================+
    // returns the connection
    //+======================================================+
    public function getconnection(){
       return $this->connection;
    }
    //+======================================================+
    // returns an object with properties rep
    //     resenting the result fields www.111cn.net and values
    //+======================================================+
    public function getobject($qry = null){
     if (isset($qry)) $this->query($qry);
     return mysql_fetch_object($this->getresult());
    }
    //+======================================================+
    // returns an array with keys representi
    //     ng the result fields and values
    //+======================================================+
    public function getarray($query_id = ""){
      if($query_id == null){
       $return = mysql_fetch_array($this->getresult());
      }else{
       $return = mysql_fetch_array($query_id);
      }
      return $return ? $return : $this->error();
    }
    //+======================================================+
    // returns the number of rows in the res
    //     ult
    //+======================================================+
      public function getnumrows($qry = null){
       if (isset($qry)) $this->query($qry);
       $amount = mysql_num_rows($this->getresult());
       return empty($amount) ? 0 : $amount;
    }
    //+======================================================+
    // returns if the result contains rows
    //+======================================================+
    public function hasresults($qry = null) {
      if (isset($qry)) $this->query($qry);
     return $this->getnumrows($qry) > 0;
    }
    //+======================================================+
    // returns the number of rows that where
    //     affected by the last action
    //+======================================================+
    public function getaffectedrows($qry = null, $query_id = null){
      if (isset($qry)) $this->query($qry);
      if(empty($query_id)){
       $return = mysql_affected_rows($this->getresult());
      }else{
       $return = mysql_affected_rows($query_id);
      }
      return $return ? $return : $this->error();
    }
    //+======================================================+
    // returns the auto generated id from th
    //     e last insert action
    //+======================================================+
    public function getinsertid($connection_link = null){
    return mysql_insert_id(isset($connection_link) ? $connection_link : $this->connection);
    }
    //+======================================================+
    // close the connection to the mysql dat
    //     abase
    //+======================================================+
    public function close(){
    if(isset($this->connection)){
    return @mysql_close($this->connection);
    }
    else {
     return $this->error();
    }
    }
    //+======================================================+
    // outputs the mysql error
    //+======================================================+
    private function error(){
    if(mysql_error() != ''){
    echo '<b>mysql errorwww.111cn.net</b>: '.mysql_error().'<br/>';
    }
    }
    }

    //demo
    // database object initialization
$db = new mysql();
$db->connect("localhost", "root", "123456", "user");

// update query
//$db->query("update table_name set field_name = value where another_field = another_value");

// select with check for record amount

if ($db->hasresults("select * from userinfo")) {
//   loop through the user records, and get them as objects
//   note that the getobject method will use the last executed query when not provided with a new one
  while ($user = $db->getobject()) {
    echo "user $user->username is called $user->password<br /> ";
  }
}
else {
  echo "no results where found";
}

[!--infotagslink--]

相关文章

  • php KindEditor文章内分页的实例方法

    我们这里介绍php与KindEditor编辑器使用时如何利用KindEditor编辑器的分页功能实现文章内容分页,KindEditor编辑器在我们点击分页时会插入代码,我们只要以它为分切符,就...2016-11-25
  • 自己动手写的jquery分页控件(非常简单实用)

    最近接了一个项目,其中有需求要用到jquery分页控件,上网也找到了需要分页控件,各种写法各种用法,都是很复杂,最终决定自己动手写一个jquery分页控件,全当是练练手了。写的不好,还请见谅,本分页控件在chrome测试过,其他的兼容性...2015-10-30
  • 不打开网页直接查看网站的源代码

      有一种方法,可以不打开网站而直接查看到这个网站的源代码..   这样可以有效地防止误入恶意网站...   在浏览器地址栏输入:   view-source:http://...2016-09-20
  • php 调用goolge地图代码

    <?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实现的个性菜单效果代码

    本文实例讲述了JS基于Mootools实现的个性菜单效果代码。分享给大家供大家参考,具体如下:这里演示基于Mootools做的带动画的垂直型菜单,是一个初学者写的,用来学习Mootools的使用有帮助,下载时请注意要将外部引用的mootools...2015-10-23
  • JS+CSS实现分类动态选择及移动功能效果代码

    本文实例讲述了JS+CSS实现分类动态选择及移动功能效果代码。分享给大家供大家参考,具体如下:这是一个类似选项卡功能的选择插件,与普通的TAb区别是加入了动画效果,多用于商品类网站,用作商品分类功能,不过其它网站也可以用,...2015-10-21
  • JS实现自定义简单网页软键盘效果代码

    本文实例讲述了JS实现自定义简单网页软键盘效果。分享给大家供大家参考,具体如下:这是一款自定义的简单点的网页软键盘,没有使用任何控件,仅是为了练习JavaScript编写水平,安全性方面没有过多考虑,有顾虑的可以不用,目的是学...2015-11-08
  • jquery实现的伪分页效果代码

    本文实例讲述了jquery实现的伪分页效果代码。分享给大家供大家参考,具体如下:这里介绍的jquery伪分页效果,在火狐下表现完美,IE全系列下有些问题,引入了jQuery1.7.2插件,代码里有丰富的注释,相信对学习jQuery有不小的帮助,期...2015-10-30
  • php 取除连续空格与换行代码

    php 取除连续空格与换行代码,这些我们都用到str_replace与正则函数 第一种: $content=str_replace("n","",$content); echo $content; 第二种: $content=preg_replac...2016-11-25
  • php简单用户登陆程序代码

    php简单用户登陆程序代码 这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。 <center> <p>&nbsp;</p> <p>&nbsp;</p> <form name="form1...2016-11-25
  • PHP实现清除wordpress里恶意代码

    公司一些wordpress网站由于下载的插件存在恶意代码,导致整个服务器所有网站PHP文件都存在恶意代码,就写了个简单的脚本清除。恶意代码示例...2015-10-23
  • js识别uc浏览器的代码

    其实挺简单的就是if(navigator.userAgent.indexOf('UCBrowser') > -1) {alert("uc浏览器");}else{//不是uc浏览器执行的操作}如果想测试某个浏览器的特征可以通过如下方法获取JS获取浏览器信息 浏览器代码名称:navigator...2015-11-08
  • JS实现双击屏幕滚动效果代码

    本文实例讲述了JS实现双击屏幕滚动效果代码。分享给大家供大家参考,具体如下:这里演示双击滚屏效果代码的实现方法,不知道有觉得有用处的没,现在网上还有很多还在用这个特效的呢,代码分享给大家吧。运行效果截图如下:在线演...2015-10-30
  • JS日期加减,日期运算代码

    一、日期减去天数等于第二个日期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
  • PHP开发微信支付的代码分享

    微信支付,即便交了保证金,你还是处理测试阶段,不能正式发布。必须到你通过程序测试提交订单、发货通知等数据到微信的系统中,才能申请发布。然后,因为在微信中是通过JS方式调用API,必须在微信后台设置支付授权目录,而且要到...2014-05-31
  • vue.js 表格分页ajax 异步加载数据

    Vue.js通过简洁的API提供高效的数据绑定和灵活的组件系统.这篇文章主要介绍了vue.js 表格分页ajax 异步加载数据的相关资料,需要的朋友可以参考下...2016-10-20
  • PHP常用的小程序代码段

    本文实例讲述了PHP常用的小程序代码段。分享给大家供大家参考,具体如下:1.计算两个时间的相差几天$startdate=strtotime("2009-12-09");$enddate=strtotime("2009-12-05");上面的php时间日期函数strtotime已经把字符串...2015-11-24
  • php怎么用拼音 简单的php中文转拼音的实现代码

    小编分享了一段简单的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商品无限级分类代码

    ecshop商品无限级分类代码 function cat_options($spec_cat_id, $arr) { static $cat_options = array(); if (isset($cat_options[$spec_cat_id]))...2016-11-25