2 include_once('/var/www/secure.php');
3 function mysqli_field_name($result, $field_offset)
5 $properties = mysqli_fetch_field_direct($result, $field_offset);
6 return is_object($properties) ?
$properties->name
: null;
8 if ($_COOKIE['level'] == 'admin'){
9 $q = "SELECT date_time_signed, signed_name_as, VTRID, shared_email, petition_id, VoterList_table FROM signatures where signature_status = 'verified' ORDER BY id";
11 $q = "SELECT date_time_signed, signed_name_as, VTRID, shared_email, VoterList_table FROM signatures where petition_id = '$_COOKIE[petition_id]' and signature_status = 'verified' ORDER BY id";
14 $r = $petition->query($q);
16 $fields = mysqli_num_fields ( $r );
18 for ( $i = 0; $i < $fields; $i++
)
20 $header .= mysqli_field_name( $r , $i ) . "\t";
22 // https://www.php.net/manual/en/mysqli-result.fetch-row.php
23 while( $row = $r->fetch_row() )
26 foreach( $row as $value )
28 if ( ( !isset( $value ) ) ||
( $value == "" ) )
34 $value = str_replace( '"' , '""' , $value );
35 $value = '"' . $value . '"' . "\t";
39 $data .= trim( $line ) . "\n";
41 $data = str_replace( "\r" , "" , $data );
45 $data = "\n(0) Records Found!\n";
48 header("Content-type: application/octet-stream");
49 header("Content-Disposition: attachment; filename=petition_signatures_".time().".xls");
50 header("Pragma: no-cache");
52 print "$header\n$data";