<?php
require_once("../../common/connect.php");

$contents="S.No, SID, Student Name, Fathers Name, Mothers Name, Course, Contact No, Email Id\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 `step` = '9' ORDER BY `student_registration`.`student_name` ASC");
$count=0;


//While loop to fetch the records
while($row = mysql_fetch_assoc($user_query))
{
$GetPersonal=mysql_query("SELECT * FROM `step1_perosonal` WHERE `sid` = '$row[sid]'");
$GetPersonal1=mysql_fetch_assoc($GetPersonal);

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

$count+=1;
$t=$row['time'];


$contents.=$count.",";
$contents.=$row['sid'].",";
$contents.=$GetPersonal1['firstname'].' '.$GetPersonal1['middlename'].' '.$GetPersonal1['lastname'].",";
$contents.=$GetPersonal1['father_name'].",";
$contents.=$GetPersonal1['mother_name'].",";
$contents.=$GetCourse1['coursename'].",";
$contents.=$row['mobile'].",";
$contents.=$row['email']."\n";
}

$contents = strip_tags($contents); 

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

?>