<th>Party</th> <th>Constituency</th> </tr> </thead> <tbody> <?php $MPURL = new URL(str_replace('s', '', $this_page)); $style = '2'; $current_letter = 'A'; foreach ($data['data'] as $pid => $mp) { $letter = ''; if (strtoupper($mp[$order][0]) != $current_letter) { $current_letter = strtoupper($mp[$order][0]); $letter = $current_letter; } render_mps_row($mp, $style, $order, $MPURL, $letter); } ?> </tbody> </table> <?php function render_mps_row($mp, &$style, $order, $MPURL, $letter = '') { $style = $style == '1' ? '2' : '1'; ?> <tr> <td class="row"> <?php if ($letter) { echo '<a name="' . $letter . '"></a>'; }
<th>Debates spoken in the last year</th> <?php } elseif ($order == 'safety') { ?> <th>Swing to lose seat (%)</th> <?php } ?> </tr> </thead> <tbody> <?php $MPURL = new URL(str_replace('s', '', $this_page)); $style = '2'; foreach ($data['data'] as $pid => $mp) { render_mps_row($mp, $style, $order, $MPURL); } ?> </tbody> </table> <?php function render_mps_row($mp, &$style, $order, $MPURL) { // Stripes $style = $style == '1' ? '2' : '1'; $name = member_full_name(1, $mp['title'], $mp['first_name'], $mp['last_name'], $mp['constituency']); # $MPURL->insert(array('pid'=>$mp['person_id'])); ?> <tr> <td class="row">
} elseif ($order == 'debates') { print ',Debates spoken in the last year'; } print "\n"; $opik = array(); foreach ($data['data'] as $n => $mp) { // Lembit Opik is special if ($mp['last_name'] == 'Öpik') { $opik = $mp; continue; } if ($opik && strcmp('Opik', $mp['last_name']) < 0) { render_mps_row($opik, $order); $opik = array(); } render_mps_row($mp, $order); } function render_mps_row($mp, $order) { global $parties; $con = html_entity_decode($mp['constituency']); if (strstr($con, ',')) { $con = "\"{$con}\""; } print $mp['person_id'] . ','; print html_entity_decode($mp['first_name']) . ',' . html_entity_decode($mp['last_name']) . ','; if (array_key_exists($mp['party'], $parties)) { print $parties[$mp['party']]; } else { print $mp['party']; }