php数组函数:在php中使用数组排序函数对表格排序



      用php排序  .gif' />_multisort对从mysql数据库查出多条记录进行排序非常简单下面简单介绍说明并给出个例子

    原形是.gif' />_multisort($sortKeyArray,$ascOrDesc,$sortArray)个参数是为了保持键值对应关系需要构建排序列第 2个参数是预定义常量SORT_ASC - 按照上升顺序排序SORT_DESC - 按照下降顺序排序第 3个参数就是所要被排序还有个可缺省参数是排序数据类型这里略过下下面例子就会明了

<?php

 Storage
   {
         function getSellList
       {
         global $db;
        $db->query(\" names utf8\");
       $db->query(\"select * from sold_record\");
       while ($row=$db->get_.gif' />)
      {
          $.gif' />=$row;
        }
        $db->free;
         $.gif' />;
      } 
  }

$storage= Storage;
    $sellList=$storage->getSellList;
    foreach ($sellList as $key => $row)
     {
            $cust[$key]  = $row[’customer_id’];
   $prod[$key] = $row[’product’];
            $pty[$key] = $row[’ptype’];
   $sdt[$key]=$row[’sell_date’];
        }
  $asdes=\"yes\";
  ($_GET[up]\"yes\")
   {
       $asdes=\"no\";
       $sort=SORT_DESC;
   }
   ($_GET[up]\"no\")
   {
       $asdes=\"yes\";
       $sort=SORT_ASC;
    
   }
   
        switch ($_GET[order])
  {
       \"cname\":
   .gif' />_multisort($cust,$sort,$sellList);
   ; [Page]
    \"product\":
   .gif' />_multisort($prod,$sort,$sellList);
   ;
    \"ptype\":
   .gif' />_multisort($pty,$sort,$sellList);
   ;
    \"date\":
   .gif' />_multisort($sdt,$sort,$sellList);
   ;
  }
    
   ?>

接下来就由大家自己想办法完成了哦呵呵!
Tags:  函数数组 函数指针数组 php数组排序 php数组函数

延伸阅读

最新评论

发表评论