require "./nav.inc"; ?> | Mercenariesif (!$db->canConnect()) // if we can't connect, throw an error. echo "ERROR: -> ".$db->getError().""; $Sort_Array = Array ("", "name", "salary", "health", "agility", "dexterity", " wisdom", "medical", "explosives", "mechanical", "marksman", "exp"); if ($cq){ $search="true"; switch ($cq): case "med":{ $SortedBy = "7"; $SearchQty = "10"; } case "expl":{ $SortedBy = "8"; $SearchQty = "10"; } break; case "mech":{ $SortedBy = "9"; $SearchQty = "10"; } break; case "mark":{ $SortedBy = "10"; $SearchQty = "10"; } endswitch; } if ($search){ // determine if we are serching, or are just going to display all $eq = "="; $gt = ">"; $lt = "<"; $query = "SELECT * FROM jadgMercs "; // begin the query for searching if ($SearchIn && $SearchFor){ // are we looking fro anything specifc, or just a sort on the main table. $query .= "WHERE {$Sort_Array[$SearchIn]} ${$SearchFor} "; //where we are searching and the relation $value = htmlspecialchars($SearchValue); // encode the value for shitheads $query .= " '$value' "; } if (!$SortedBy) // no sort set, so set it to the field they are searching against. $SortedBy = $SearchIn; } else{ // first time or reset, simple search $query = "SELECT * FROM jadgMercs"; $SortedBy = "1,R"; } switch ($SearchQty): case 10: $myLimit = "LIMIT 0, 10"; break; case 20: $myLimit = "LIMIT 0, 20"; break; default: $myLimit = ""; endswitch; list($sort, $reverse) = split(",",$SortedBy); // split the sored by if (($sort) && ($sort >=1 && $sort <=11) ){ // valid range $query .= " ORDER BY {$Sort_Array[$sort]} "; if ($reverse == "R") // see if we need to reverse the sort $query .= "ASC $myLimit"; else $query .= "DESC $myLimit"; } else{ // not a valid range, default to name. $query .= " ORDER BY name DESC $myLimit"; } $result = $db->runQuery($query); //echo "$query Returned ".$db->getResultCount()." "; /* Toggle the sort order. */ function getReverse($current){ global $sort, $reverse; if (($sort == $current) && ($reverse != "R")) return ",R"; else return ""; } /* Determine selection for drop downs. */ function isSelected($one, $two){ if ($one == $two) return " selected "; else return ""; } ?>
echo "Returned ".$db->getResultCount()." mercenaries. "; ?> |