summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Kinkade <nath@nkinka.de>2014-04-12 12:25:27 +0000
committerNathan Kinkade <nath@nkinka.de>2014-04-12 12:25:27 +0000
commita670c3f81ff441271054336fa2c3eb25c08b6576 (patch)
treee15ccac0323fddb3eb93223655da68ec2a87631d
parentb5f0804602055fd2637c784bb66cfe559fc80525 (diff)
Added the ability to search by a range of case numbers.
-rw-r--r--index.php4
-rw-r--r--search.php16
-rw-r--r--style.css2
3 files changed, 20 insertions, 2 deletions
diff --git a/index.php b/index.php
index 16cc010..b84f90c 100644
--- a/index.php
+++ b/index.php
@@ -32,7 +32,9 @@ for ( $year = date("Y"); $year >= 1990; $year-- ) {
<div>
<label for="case_num">Case #</label>
- <input type="text" id="case_num" name="case_num" maxlength="6" />
+ <input type="text" class="case_num" id="case_num" name="case_num" maxlength="6" />
+ to
+ <input type="text" class="case_num" id="case_num_to" name="case_num_to" maxlength="6" />
</div>
<div>
diff --git a/search.php b/search.php
index 6aadeef..936b6c0 100644
--- a/search.php
+++ b/search.php
@@ -49,6 +49,7 @@ $request_params = array(
'between' => '',
'case_years' => '',
'case_num' => '',
+ 'case_num_to' => '',
'defendant' => '',
'name' => '',
'charge' => '',
@@ -95,6 +96,21 @@ if ( $case_id ) {
$where_parts_and[] = "id = '$case_id'";
}
+// There are a limited set of circumstances where using a range will work, as
+// the MySQL between operator doesn't always work with wildcards. Unset case
+// $case_years and $case_num and then populate $between, since we already have
+// code to handle that.
+if ( $case_num_to ) {
+ $case_year = substr($case_years[0], -2);
+ $case_num = str_pad($case_num, 6, '0', STR_PAD_LEFT);
+ $case_num_to = str_pad($case_num_to, 6, '0', STR_PAD_LEFT);
+ $range_start = "F-{$case_year}-{$case_num}";
+ $range_end = "F-{$case_year}-{$case_num_to}";
+ $between = "$range_start:$range_end";
+ unset($case_years);
+ unset($case_num);
+}
+
if ( $between ) {
list($btwn_start, $btwn_end) = explode(':', $between);
$where_parts_and[] = "court_case_no BETWEEN '$btwn_start' AND '$btwn_end'";
diff --git a/style.css b/style.css
index 5f2c712..ee8dd7a 100644
--- a/style.css
+++ b/style.css
@@ -44,7 +44,7 @@ tr.alt {
background-color: #eeeeee;
}
-#case_num { width: 5em; }
+.case_num { width: 5em; }
#search_cases div {
margin-bottom: 1ex;