bugfix in GET hand validation
bugfix in GET hand validation

--- a/include/classes/display.php
+++ b/include/classes/display.php
@@ -31,11 +31,11 @@
 	 * @return void
 	 */
 
-	public function page ($page, $hand="", $card="", $ajax=false) {
+	public function page ($page, $hand=-1, $card="", $ajax=false) {
 
 		$sqlFilter = "WHERE 1=1";
 		$params = "";
-		if ($hand != "") {
+		if ($hand >= 0) {
 			$sqlFilter .= " AND `hand`='".$hand."'";
 			$params .= "&hand=".$hand;
 		}

file:a/index.php -> file:b/index.php
--- a/index.php
+++ b/index.php
@@ -9,7 +9,7 @@
 $display = new Display;
 
 $page = filter_var ($_GET['page'], FILTER_VALIDATE_INT);
-$hand = filter_var ($_GET['hand'], FILTER_VALIDATE_INT);
+$hand = ($_GET['hand'] != "") ? filter_var ($_GET['hand'], FILTER_VALIDATE_INT) : "-1";
 $card = filter_var ($_GET['card'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
 $ajax = filter_var ($_GET['ajax'], FILTER_VALIDATE_BOOLEAN);
 

--- a/style/tpl/index.tpl
+++ b/style/tpl/index.tpl
@@ -27,7 +27,7 @@
 			<td>
 				<form id="filterform" method="get" action="">
 	    			<select name="hand" id="hand">
-	    				<option value="">all - {$stats.all}</option>
+	    				<option value="-1">all - {$stats.all}</option>
 						{foreach key=k item=v from=$hands}
 						<option value="{$k}"{if $currentHand && $currentHand == $k} selected="selected"{/if}>{$v} - {$stats.$k}</option>
 						{/foreach}

--- a/style/tpl/pagination.tpl
+++ b/style/tpl/pagination.tpl
@@ -1,7 +1,7 @@
 <table class="widefat post fixed">
 <tr>
 	<td id="pagination">
-		{if $currentHand != ""}
+		{if $currentHand >= 0}
 			Showing <strong>{$hands.$currentHand}{if $currentCard}/{$currentCard}{/if}</strong> combinations
 		{else}
 			Showing <strong>all{if $currentCard}/{$currentCard}{/if}</strong> combinations

comments