<?php
// Connection 

include '../Model/configuration.php';

$filename = "Webinfopen.xls"; // File Name
// Download file
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
$user_query = 'SELECT c_title as Title,c_fname as First_name,c_lname as Last_Name, c_star as Important, (SELECT `contacttitle_name` FROM `sales_contact_title` WHERE `id`=c_jobtitle) as Job_Title,c_na_status as Status, c_na_closingdate as close_date, c_a_line as Line1, c_a_city as City, c_a_state as State,	c_a_country as Country,	c_a_pincode as Pincode,	c_background as Background,	c_owner_name as Owner_name,c_private as Private, c_dob as Date_of_Brith,	c_dtime, o_id, o_name, o_desc, o_phone, o_url, o_line,	o_city,	o_state, o_country,	o_pincode, s_name, s_desc, s_color,	t_name,	t_desc as Description, l_name as lead_Name FROM sales_contact_organization_status_tag_leadsource WHERE `c_owner_id`!="velemailid2@gmail.com" and `c_companyname`="webnew" and `c_emailid`="velemailid2@gmail.com" and sales_contact_organization_status_tag_leadsource.c_delete="no"';
// Write data to file
$result = $conn->query($user_query);
$flag = false;
while ($row = $result->fetch_assoc()) {
    if (!$flag) {
        // display field/column names as first row
        echo implode("\t", array_keys($row)) . "\r\n";
        $flag = true;
    }
    echo implode("\t", array_values($row)) . "\r\n";
}
?>