diff --git a/website/election2007.php b/website/election2007.php index aec89305..e212f942 100644 --- a/website/election2007.php +++ b/website/election2007.php @@ -1,6 +1,6 @@ 0, "foia"=>1, "lrrb"=>2, "smoking"=>3, "trident"=>4); +$policystrnum = array("iraq"=>0, "foia"=>1, "lrrb"=>2, "smoking"=>3, "trident"=>4); +$policynumstr = array_flip($policystrnum); // Name in database => display name $parties = array( @@ -95,7 +96,7 @@ ); - +/* // Grab shorter URL if it is one $qstring = $_SERVER["QUERY_STRING"]; $shorter_url = false; @@ -112,24 +113,29 @@ } $shorter_url = true; } +*/ // Validate if a submit $errors = array(); if ($_GET['submit']) { + $mpattr = null; $constituency = postcode_to_constituency($db, $_GET['mppc'], $postcode_year); - $row = $db->query_onez_row_assoc("select * from pw_mp where constituency = '$constituency' - and ($date_clause)"); - if ($row) - $mpid = $row['mp_id']; - $mpattr = get_mpid_attr($db, $db2, $mpid, false, 1, null); - if ($mpattr == null) { - $errors[] = "Your MP wasn't found. Please check you - entered the postcode correctly."; +$constituency = "Kirkcaldy & Cowdenbeath"; // XXX temp + if ($constituency) { + $row = $db->query_onez_row_assoc("select * from pw_mp where constituency = '$constituency' + and ($date_clause)"); + if ($row) + $mpid = $row['mp_id']; + $mpattr = get_mpid_attr($db, $db2, $mpid, false, 1, null); + if ($mpattr == null) { + $errors[] = "Your MP wasn't found. Please check you + entered the postcode correctly."; + } } } // Redirect to shorter URL -if ($_GET['submit'] and !$errors and !$shorter_url) { +/*if ($_GET['submit'] and !$errors and !$shorter_url) { $qpc = strtoupper(trim($_GET['mppc'])); $qpc = str_replace(" ", "", $qpc); $quick = "?$qpc;"; @@ -140,7 +146,7 @@ header("Location: /election2007.php$quick\n"); return; -} +}*/ header("Content-Type: text/html; charset=UTF-8"); ?> @@ -156,6 +162,7 @@ if ($_GET['submit'] /*and !$errors*/) { + # See if MP is standing again $mpattr = $mpattr['mpprops'][0]; $constituency = str_replace("&", "&", $mpattr['constituency']); @@ -170,19 +177,20 @@ $consid = normalise_constituency_name($db, strtolower($constituency), "2001"); if (!$consid) { print "
"; print_r($questmap); print ""; - if (!$polfill[$polval]) + if ($mpattr) { + $polfill = array(); + foreach ($questlistmaps as $questmap) { - print "
"; print_r($questmap); print ""; - # XXX should be only when MP is standing again - $divdate = $questmap["date"]; - $divnum = $questmap["divisionno"]; - $query = "select vote from pw_vote - left join pw_mp on pw_mp.mp_id = pw_vote.mp_id - left join pw_division on pw_division.division_id = pw_vote.division_id - where pw_mp.person = " . $mpattr['person'] . " - and pw_division.division_date = '" . $divdate . "' and pw_division.division_number = " . $divnum . " - "; - list ($mpvote) = $db->query_onez_row($query); - if (!$mpvote) - $mpvote = "absent"; - print $mpvote . " --> " . $questmap["mpvote"] . "
"; print_r($questmap); print ""; + if (!$polfill[$polval]) + { + #print "
"; print_r($questmap); print ""; + # XXX should be only when MP is standing again + $divdate = $questmap["date"]; + $divnum = $questmap["divisionno"]; + $query = "select vote from pw_vote + left join pw_mp on pw_mp.mp_id = pw_vote.mp_id + left join pw_division on pw_division.division_id = pw_vote.division_id + where pw_mp.person = " . $mpattr['person'] . " + and pw_division.division_date = '" . $divdate . "' and pw_division.division_number = " . $divnum . " + "; + list ($mpvote) = $db->query_onez_row($query); + if (!$mpvote) + $mpvote = "absent"; + #print $mpvote . " --> " . $questmap["mpvote"] . "
"; print_r($polfill); print ""; ?>