Commit: 683df30c402fb220e908af4a5f64e2fc9ec4d3a9 Author: Hannes Magnusson <[email protected]> Sun, 29 Dec 2013 01:50:43 -0800 Parents: 11aa634bae9efc96ed49a135b00873e944c48663 Branches: master
Link: http://git.php.net/?p=web/master.git;a=commitdiff;h=683df30c402fb220e908af4a5f64e2fc9ec4d3a9 Log: Order by asc/desc Changed paths: M include/functions.inc M manage/users.php Diff: diff --git a/include/functions.inc b/include/functions.inc index da4fd20..05a5ffe 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -153,12 +153,20 @@ function db_get_one($query) // ----------------------------------------------------------------------------------- function array_to_url($array,$overlay=array()) { - if ($overlay) $array = array_merge($array,$overlay); - $out = ""; - while (list($k,$v) = each($array)) { - $out .= "&" . rawurlencode($k) . "=" . rawurlencode($v); - } - return substr($out,5); # skip first & + $params = array(); + foreach($array as $k => $v) { + $params[$k] = rawurlencode($k) . "=" . rawurlencode($v); + } + foreach($overlay as $k => $v) { + if ($array[$k] == $v) { + $params["forward"] = $array["forward"] ? "forward=0" : "forward=1"; + continue; + } + $params["forward"] = "forward=0"; + $params[$k] = rawurlencode($k) . "=" . rawurlencode($v); + } + + return join($params, "&"); } function show_prev_next($begin, $rows, $skip, $total, $extra = array(), $table = true) diff --git a/manage/users.php b/manage/users.php index 3f42ec0..3a3d024 100644 --- a/manage/users.php +++ b/manage/users.php @@ -273,6 +273,7 @@ table.useredit tr { $unapproved = filter_input(INPUT_GET, "unapproved", FILTER_VALIDATE_INT) ?: 0; $begin = filter_input(INPUT_GET, "begin", FILTER_VALIDATE_INT) ?: 0; $max = filter_input(INPUT_GET, "max", FILTER_VALIDATE_INT) ?: 20; +$forward = filter_input(INPUT_GET, "forward", FILTER_VALIDATE_INT) ?: 0; $search = filter_input(INPUT_GET, "search", FILTER_CALLBACK, array("options" => "mysql_real_escape_string")) ?: ""; $query = "SELECT DISTINCT SQL_CALC_FOUND_ROWS users.userid,cvsaccess,username,name,email FROM users "; @@ -288,7 +289,12 @@ if ($unapproved) { } if ($order) { - $query .= " ORDER BY $order "; + if ($forward) { + $ext = "ASC"; + } else { + $ext = "DESC"; + } + $query .= " ORDER BY $order $ext"; } $query .= " LIMIT $begin,$max "; $res = db_query($query); @@ -301,6 +307,7 @@ $total = mysql_result($res2,0); $extra = array( "search" => $search, "order" => $order, + "forward" => $forward, "begin" => $begin, "max" => $max, "unapproved" => $unapproved, -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
