时间:2021-07-01 10:21:17 帮助过:22人阅读
- php
- class Storage
- {
- function getSellList()
- {
- global $db;
- $db->query("set names utf8");
- $db->query("select * from sold_record");
- while ($row=$db->get_array())
- {
- $array[]=$row;
- }
- $db->free();
- return $array;
- }
- }
- $storage=new 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";
- if($_GET[up]=="yes")
- {
- $asdes="no";
- $sort=SORT_DESC;
- }
- elseif($_GET[up]=="no")
- {
- $asdes="yes";
- $sort=SORT_ASC;
- }
- switch ($_GET[order])
- {
- case "cname":
- array_multisort($cust,$sort,$sellList);
- break;
- case "product":
- array_multisort($prod,$sort,$sellList);
- break;
- case "ptype":
- array_multisort($pty,$sort,$sellList);
- break;
- case "date":
- array_multisort($sdt,$sort,$sellList);
- break;
- }
- ?>
上面这段代码就是PHP数组排序函数array_multisort对表格排序的具体代码编写。
http://www.bkjia.com/PHPjc/446380.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/446380.htmlTechArticle我们今天为大家带来的是一个 函数的原形是array_multisort($sortKeyArray,$ascOrDesc,$sortArray),PHP数组排序函数array_multisort中的第一个参数是为了保...