<?php require_once('../Connections/oprmConn.php'); include('check-admin-session.php');
mysql_select_db($database_oprmConn, $oprmConn);
$query_MembersList = "select * FROM weby_profiles ORDER BY full_name ASC";
$MembersList = mysql_query($query_MembersList, $oprmConn) or die(mysql_error());
$row_MembersList = mysql_fetch_assoc($MembersList);
$totalRows_MembersList = mysql_num_rows($MembersList);

Header("Content-Disposition: attachment; filename=profile.csv");
?>
User #,Name,Email Address,Job Title,Skill Set,Profile Pic,CV File,Passport File,Visa File,NI Number,Holiday Sheet,Other Info,Bank Account,Bank Sortcode,Bank Address,Passport Number,Visa Number,Passport Endate,Visa Endate,Citizen Of,Kin Name,Kin Phone No,Kin Mail Address,Kin Address,Contact Phone No,Contact Address,Created Date,Status
<?php do { ?>

<?php echo $row_MembersList['user_id']; ?>,<?php echo $row_MembersList['full_name']; ?>,<?php 
mysql_select_db($database_oprmConn, $oprmConn);
$query_getPid = "select weby_users.email_address FROM weby_users where weby_users.user_id = '$row_MembersList[user_id]'";
$getPid = mysql_query($query_getPid, $oprmConn) or die(mysql_error());
$row_getPid = mysql_fetch_assoc($getPid);
$totalRows_getPid = mysql_num_rows($getPid);
echo $row_getPid['email_address']; ?>,<?php $aa = str_replace(",","-",$row_MembersList['job_title']); echo $aa1 =  str_replace("\n","-",$aa); echo str_replace("\r","-",$aa1); ?>,<?php	$a1 = str_replace(",","-",$row_MembersList['skill_set']); $a11 = str_replace("\n","-",$a1); echo str_replace("\r","-",$a11); ?>,<?php echo $row_MembersList['profile_pic']; ?>,<?php echo $row_MembersList['cv_file']; ?>,<?php echo $row_MembersList['passport_file']; ?>,<?php echo $row_MembersList['visa_file']; ?>,<?php echo $row_MembersList['ni_number']; ?>,<?php echo $row_MembersList['holiday_sheet']; ?>,<?php $ab = str_replace(",","-",$row_MembersList['other_info']); $ab1 = str_replace("\n","-",$ab); echo str_replace("\r","-",$ab1); ?>,<?php echo $row_MembersList['bank_account'];  ?>,<?php echo $row_MembersList['bank_sortcode']; ?>,<?php $ac = str_replace(",","-",$row_MembersList['bank_address']); $ac1 = str_replace("\n","-",$ac); echo str_replace("\r","-",$ac1); ?>,<?php echo date("d-m-Y",strtotime($row_MembersList['date_of_birth'])); ?>,<?php echo $row_MembersList['passport_number']; ?>,<?php echo $row_MembersList['visa_number']; ?>,<?php echo date("d-m-Y",strtotime($row_MembersList['passport_edate'])); ?>,<?php echo date("d-m-Y",strtotime($row_MembersList['visa_edate'])); ?>,<?php echo $row_MembersList['citizen_of']; ?>,<?php echo $row_MembersList['kin_name']; ?>,<?php echo $row_MembersList['kin_phone']; ?>,<?php echo $row_MembersList['kin_email']; ?>,<?php $ad = str_replace(",","-",$row_MembersList['kin_address']); $ad1 = str_replace("\n","-",$ad); echo str_replace("\r","-",$ad1); ?>,<?php echo $row_MembersList['contact_phone']; ?>,<?php $ae = str_replace(",","-",$row_MembersList['contact_address']); echo str_replace("\n","-",$ae); $ae1 = str_replace("\r","-",$ae1); ?>,<?php echo date("d-m-Y",strtotime($row_MembersList['created_date'])); ?>,<?php if($row_MembersList['status'] == 'A'){echo'Active'; } if($row_MembersList['status'] == 'P'){ echo'Pending';} if($row_MembersList['status'] == 'D'){ echo'Deleted';} ?>
		<?php } while ($row_MembersList = mysql_fetch_assoc($MembersList)); ?>

<?php
mysql_free_result($MembersList);
?>
