<?php

  /*

      sorting.php

      Contains some database access functions for ease of use.
    
    ## PAGE CONTAINS HANDYANDY MYSQL MODS ##
    ## Copyright (C) 2005 Andy Deakin (handyandy.org.uk) ##

      ----

      Copyright (C) 2003  Central Manchester CLC
      Copyright (C) 2003  David Thorne (davethorne@gmail.com)

      This program is free software; you can redistribute it and/or
      modify it under the terms of the GNU General Public License
      as published by the Free Software Foundation version 2.

      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.

      You should have received a copy of the GNU General Public License
      along with this program; if not, write to the Free Software
      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

  */
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__, '.php')) !== false) {
  header("location: index.php");
}
  function makeordering($inputorderby,$orderby1,$orderdir1) {
    if ($orderby1 == $inputorderby) {
      if ($orderdir1 == 'DESC') {
        $direction = 'ASC';
      } else {
        $direction = 'DESC';
      }
    } else {
      $direction = 'ASC';
    }
    print "orderby=$inputorderby&amp;orderdir=$direction";
  }

  function makeordering2($inputorderby,$orderby1,$orderdir1) {
    if ($orderby1 == $inputorderby) {
      if ($orderdir1 == 'DESC') {
        $direction = 'ASC';
      } else {
        $direction = 'DESC';
      }
    } else {
      $direction = 'ASC';
    }
    print "orderby2=$inputorderby&amp;orderdir2=$direction";
  }

  function makesymbol($inputorderby,$orderby1,$orderdir1) {
    if ($orderby1 == $inputorderby) {
      if ($orderdir1 == 'DESC') {
        $symbol = '&uarr;';
      } else {
        $symbol = '&darr;';
      }
    } else {
      $symbol = '';
    }
    print $symbol;
  }
?>
