<?php
error_reporting(0);
ob_start();
session_start();
require_once("../common/connect.php");
$ses = $_SESSION['ses_id'];

$contents="S.No, SID, Student Name, Course, Contact No, Email Id, Date, Status\n";

//Mysql query to get records from datanbase
//You can customize the query to filter from particular date and month etc...Which will depends your database structure.
$user_query = mysql_query("SELECT * FROM `student_registration` WHERE  `sesion` ='9' ORDER BY  `student_registration`.`master_id` DESC");

$count=0;

//While loop to fetch the records
while($row = mysql_fetch_assoc($user_query))
{


if($row['step']=='1')
{
$step='Personal Desk';	
}

if($row['step']=='2')
{
$step='Academic Detail Desk';	
}

if($row['step']=='3')
{
$step='Document Desk';	
}

if($row['step']=='4')
{
$step= 'Payment desk';	
}

if($row['step']=='5')
{
$step='DD Desk';	
}

if($row['step']=='6')
{
$step='Scruitnizer Desk';	
}

if($row['step']=='7')
{
$step= 'Senior Desk';	
}

if($row['step']=='8')
{
$step='Finance Desk';	
}
if($row['step']>='9')
{
$step= 'Admission Done';	
}


$count+=1;
$t=$row['time'];
$t2=date('d-m-Y', $t);

$GetCourse=mysql_query("SELECT * FROM `sgvu_courses` WHERE `course_id` ='$row[branch]'");
$GetCourse1=mysql_fetch_assoc($GetCourse);


$contents.=$count.",";
$contents.=$row['sid'].",";
$contents.=strtoupper($row['student_name']).",";
$contents.=strtoupper($GetCourse1['coursename']).",";
$contents.=strtoupper($row['mobile']).",";
$contents.=$row['email'].",";
$contents.=$t2.",";
$contents.=$step."\n";
}

$contents = strip_tags($contents); 

header("Content-Disposition: attachment; filename=total-sid-list.csv");
print $contents;

?>