Your IP : 3.145.89.181
<?php
if(!isset($_SESSION['admin'])){ header("location: index.php"); exit;}
$rep = $_SESSION['admin'];
$rid = $_SESSION['rid'];
$sid = $_SESSION['sid'];
$region = $_SESSION['region'];
$state = $_SESSION['state'];
define("DB_SERVER", "localhost");
define("DB_USER", "lentoinv_churchm");//enter your database username
define("DB_PASS", "AGpDH0&Zhev");//databse password
define("DB_NAME", "lentoinv_churchm");//database name
$db = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
if($_SESSION['page']==1){
$dsn= $_SESSION['dsn'];
$did = $dsn;
$query=$db->query("select * FROM district WHERE sn='$dsn' " )or die(mysql_error());
$ro=mysqli_fetch_array($query);
$district = $ro['district'];
$zone = $ro['zone'];
$dc = $ro['dc'];
$phone = $ro['phone'];
$gsn = $ro['gid'];
$gid = $ro['gid'];
$rid = $ro['rid'];
$sid = $ro['sid'];
$hq = $ro['hq'];
} elseif($_SESSION['page']==2){
$gid = $_SESSION['gid'] ;
$query=$db->query("select * FROM zone WHERE sn='$gid' " )or die(mysql_error());
$ro=mysqli_fetch_array($query);
$zone = $ro['zone'];
$gc = $ro['gc'];
$phone = $ro['phone'];
$rid = $ro['rid'];
$sid = $ro['sid'];
}elseif($_SESSION['page']==3){
$regnox = $_SESSION['regno'];
$quer=$db->query("select * FROM mdata WHERE regno='$regnox' " )or die(mysql_error()); $ro=mysqli_fetch_array($quer);
$dsn = $ro['did'];
$did = $ro['did'];
$gid = $ro['gid'];
$rid = $ro['rid'];
$sid = $ro['sid'];
}elseif($_SESSION['page']==4){
$username = $_SESSION['username'];
$rid = $_SESSION['rid'];
$sid = $_SESSION['sid'];
$region = $_SESSION['region'];
$state = $_SESSION['state'];
/*$query=$db->query("select * FROM admin WHERE username='$username' " )or die(mysql_error());
$ro=mysql_fetch_array($query);
$rid = $ro['rid'];
$sid = $ro['sid'];
*/
}
function user($id,$col){
global $db;
$qur=$db->query("select * FROM mdata WHERE sn='$id' ")or die(mysqli_error());
$r=mysqli_fetch_assoc($qur);
return $r[$col];
}
function ymdToDate($ymd,$col='date'){
global $db;
$queryy=$db->query("SELECT * FROM progs WHERE ymd = '$ymd' " )or die(mysqli_error());
$row=mysqli_fetch_array($queryy);
return $row[$col];
}
function gName($gid,$col='zone'){
global $db;
$query=$db->query("select * FROM zone WHERE sn='$gid' " )or die(mysql_error());
$row=mysqli_fetch_array($query);
return $row[$col];
}
function dName($did,$col='district'){
global $db;
$query=$db->query("SELECT * FROM district WHERE sn='$did' " )or die(mysql_error());
$row=mysqli_fetch_array($query);
return $row[$col];
}
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 sanitize($str){
global $db;
$res = mysqli_real_escape_string($db, $str);
return ucwords(strtolower(trim($res)));
}
function findSection($sec){
global $db,$did;
$sql=$db->query("SELECT * FROM mdata WHERE did = '$did' AND section='$sec' " )or die(mysqli_error());
return mysqli_num_rows($sql);
}
function findSectiongd($sec){
global $db,$gid;
$sql=$db->query("SELECT * FROM mdata WHERE gid = '$gid' AND section='$sec' " )or die(mysqli_error());
return mysqli_num_rows($sql);
}
function statSection($sec,$sex){
global $db,$did;
$sql=$db->query("SELECT * FROM mdata WHERE did = '$did' AND section='$sec' AND sex='$sex' " )or die(mysqli_error());
return mysqli_num_rows($sql);
}
function statSectiongd($sec,$sex){
global $db,$gid;
$sql=$db->query("SELECT * FROM mdata WHERE gid = '$gid' AND section='$sec' AND sex='$sex' " )or die(mysqli_error());
return mysqli_num_rows($sql);
}
function dStrength($did,$sex=''){
global $db;
$sql = $sex=='' ? $db->query("SELECT * FROM mdata WHERE did = '$did' " ) : $db->query("SELECT * FROM mdata WHERE did = '$did' AND sex='$sex' " ) ;
return mysqli_num_rows($sql);
}
function gStrength($gid,$sex=''){
global $db;
$sql = $sex=='' ? $db->query("SELECT * FROM mdata WHERE gid = '$gid' " ) : $db->query("SELECT * FROM mdata WHERE gid = '$gid' AND sex='$sex' " ) ;
return mysqli_num_rows($sql);
}
function rStrength($rid,$sex=''){
global $db;
$sql = $sex=='' ? $db->query("SELECT * FROM mdata WHERE rid = '$rid' " ) : $db->query("SELECT * FROM mdata WHERE rid = '$rid' AND sex='$sex' " ) ;
return mysqli_num_rows($sql);
}
function allSection($sec){
global $db;
$sql=$db->query("SELECT * FROM mdata WHERE section='$sec' " )or die(mysqli_error());
return mysqli_num_rows($sql);
}
function allStrength(){
global $db;
$sql=$db->query("SELECT * FROM mdata " )or die(mysqli_error());
return mysqli_num_rows($sql);
}
function gSecSex($gid,$sec,$sex=''){
global $db;
$sql = $sex=='' ? $db->query("SELECT * FROM mdata WHERE gid = '$gid' AND section='$sec' " ) : $db->query("SELECT * FROM mdata WHERE gid = '$gid' AND section='$sec' AND sex='$sex' " ) ;
return mysqli_num_rows($sql);
}
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 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);
}
?>