Your IP : 3.145.168.68
<?php
if(!isset($_SESSION['admin'])){ header("location: index.php"); exit;}
date_default_timezone_set('Africa/Lagos');
$rep = $_SESSION['admin'];
$rid = $_SESSION['rid'];
$sid = $_SESSION['sid'];
//$region = $_SESSION['region'];
//$state = $_SESSION['state'];
define("DB_SERVER", "localhost");
define("DB_USER", "root");//enter your database username
define("DB_PASS", "");//databse password
define("DB_NAME", "churchmr");//database name
$db = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
function userName($id,$col=''){
global $db;
$query=$db->query("SELECT * FROM mdata WHERE id='$id' " )or die(mysql_error());
$row=mysqli_fetch_array($query);
$res = empty($col) ? $row['surname'].' '.$row['firstname'].' '.$row['othername'] : $row[$col];
return $res;
}
function win_hashs($length){
return substr(str_shuffle(str_repeat('123456789abcdefghijklmnopqrstuvwxyz',$length)),0,$length);
}
function win_hash($length){
return substr(str_shuffle(str_repeat('123456789',$length)),0,$length);
}
function sanitize($str){
global $db;
$res = mysqli_real_escape_string($db, $str);
return ucwords(strtolower(trim($res)));
}
function sqLx($table,$col,$val,$item){
global $db;
$sql=$db->query("SELECT * FROM $table WHERE $col='$val' ")or die(mysqli_error());
$row = mysqli_fetch_assoc($sql);
return $row[$item];
}
function sqLx2($table,$col,$val,$col2,$val2,$item){
global $db;
$sql=$db->query("SELECT * FROM $table WHERE $col='$val' AND $col2='$val2' ")or die(mysqli_error());
$row = mysqli_fetch_assoc($sql);
return $row[$item];
}
function sqLx3($table,$col,$val,$col2,$val2,$col3,$val3,$item){
global $db;
$sql=$db->query("SELECT * FROM $table WHERE $col='$val' AND $col2='$val2' AND $col3='$val3' ")or die(mysqli_error());
$row = mysqli_fetch_assoc($sql);
return $row[$item];
}
function sqLx4($table,$col1,$val1,$col2,$val2,$col3,$val3,$col4,$val4,$item){
global $db;
$sql=$db->query("SELECT * from $table where $col1='$val1' and $col2='$val2' and $col3='$val3' and $col4='$val4' " );
$row = mysqli_fetch_assoc($sql);
return $row[$item];
}
function sqL($table){
global $db;
$sql=$db->query("SELECT * FROM $table ")or die(mysqli_error());
return mysqli_num_rows($sql);
}
function sqL1($table,$col,$val){
global $db;
$sql=$db->query("SELECT * FROM $table WHERE $col='$val' ")or die(mysqli_error());
return mysqli_num_rows($sql);
}
function sqL2($table,$col,$val,$col2,$val2){
global $db;
$sql=$db->query("SELECT * FROM $table WHERE $col='$val' AND $col2='$val2' ")or die(mysqli_error());
return mysqli_num_rows($sql);
}
function sqL3($table,$col,$val,$col2,$val2,$col3,$val3){
global $db;
$sql=$db->query("SELECT * FROM $table WHERE $col='$val' AND $col2='$val2' AND $col3='$val3' ")or die(mysqli_error());
return mysqli_num_rows($sql);
}
function sqL4($table,$col,$val,$col2,$val2,$col3,$val3,$col4,$val4){
global $db;
$sql=$db->query("SELECT * FROM $table WHERE $col='$val' AND $col2='$val2' AND $col3='$val3' AND $col4='$val4' ")or die(mysqli_error());
return mysqli_num_rows($sql);
}
function colSum($table,$col){
global $db;
$sql=$db->query("SELECT SUM($col) AS value_sum FROM $table where sid = SID ");
$row = mysqli_fetch_assoc($sql);
return $row['value_sum'];
}
function colSum1($table,$col,$cola,$vala){
global $db;
$sql=$db->query("SELECT SUM($col) AS value_sum FROM $table WHERE $cola = '$vala' ");
$row = mysqli_fetch_assoc($sql);
return $row['value_sum'];
}
function colSum2($table,$col,$cola,$vala,$colb,$valb){
global $db;
$sql=$db->query("SELECT SUM($col) AS value_sum FROM $table WHERE $cola = '$vala' AND $colb = '$valb' ");
$row = mysqli_fetch_assoc($sql);
return $row['value_sum'];
}
function colSum3($table,$col,$cola,$vala,$colb,$valb,$colc,$valc){
global $db;
$sql=$db->query("SELECT SUM($col) AS value_sum FROM $table WHERE $cola = '$vala' AND $colb = '$valb' AND $colc = '$valc' ");
$row = mysqli_fetch_assoc($sql);
return $row['value_sum'];
}
function dTable($body,$sql){
//$body: array of table row elements
//$sql: database query
$m = count($body);
$table='';
while($row = mysqli_fetch_assoc($sql)) {
$table .= ' <tr>';
$x=0;
while($x<$m){ $y = $x++;
$b = $row[$body[$y]];
$table .= '<td>'.$b.'</td>';
}
$table .= '</tr>';
}
return $table;
}
class churchMr{
function __construct()
{
if (array_key_exists('LoginUser', $_POST)) { $this->LoginUser(); }
elseif (array_key_exists('SubmitReport', $_POST)) { $this->SubmitReport(); }
}
function LoginUser(){
//if login successful
setcookie('mid', $mid, time() + 86400*730, "/");
setcookie('did', $did, time() + 86400*730, "/");
setcookie('gid', $gid, time() + 86400*730, "/");
setcookie('rid', $rid, time() + 86400*730, "/");
setcookie('sid', $sid, time() + 86400*730, "/");
}
function districMonthlyHistory($did,$mm){
global $db;
$table='';
$sql = $db->query("SELECT * FROM report WHERE did='$did' AND mm='$mm' ORDER BY dd ");
while ($row = mysqli_fetch_assoc($sql)) {
$table .= '<tr><td>'.substr($row['prog'],0,3).' '.$row['dd'].'</td><td>'.($row['a1']+$row['a2']).'</td><td>'.($row['y1']+$row['y2']).'</td><td>'.($row['c1']+$row['c2']).'</td><td>'.$row['total'].'</td><td>'.$row['off'].'</td></tr>';
}
return $table;
}
}
$pro = new churchMr;
?>