hi all,

onclick a link i am exporting all details to excel. it's working well.
but when i uploaded this file to my domain and run it,it is fetching data but not all data, columns are exporing to excel but only first 3 value are exporting to excel.

any idea for this appre..
thankx

$cdate = date("Y-m-d"); // get current date
include("class/config.php");
$obj=new process();
$obj->connection();
$query_string = "SELECT user_register.user_id as Sno,job_apply,name as Name,Email,Country,Age,Address,Cno as ContactNumber,Mno as MobileNumber,Gender,Date_register as RegisterDate,filename as Document FROM user_register join user_upload on user_register.user_id=user_upload.user_id"; 
$export_filename = "report_$cdate.xls";


$result = mysql_query($query_string);

$count = mysql_num_fields($result);

$header = '';
for ($i = 0; $i < $count; $i++){
	$header .= mysql_field_name($result, $i)."\t";
}

while($row = mysql_fetch_row($result)){
	$line = '';
	foreach($row as $value){
		if(!isset($value) || $value == ""){
			$value = "\t";
		}else{
			$value = str_replace('"', '""', $value);
			$value = '"' . $value . '"' . "\t";
		}

		$line .= $value;
	}
	$data .= trim($line)."\n";
}

$data = str_replace("\r", "", $data);

if ($data == "") {
	$data = "\nNo Data Found\n";
}

// create table header showing to download a xls (excel) file
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=$export_filename");
header("Cache-Control: public");
header("Content-length: ".strlen($data)); // tells file size
header("Pragma: no-cache");
header("Expires: 0");
// output data
echo $header."\n".$data;

echo $query_string; exit;
Check sql query on your domain and execute in sql window, what you are getting?

echo $query_string; exit;
Check sql query on your domain and execute in sql window, what you are getting?

i already check this before but as u told me i checked it again , if i did any mistake

but query fetching all data from mysql but when printing data to excel table column are there and only 3 values fetching to excel.

please see image attached.

thnx

It might be broken in between.
Post your database record and your current excel.

Change Line no. 40 to

header("Content-Type: application/vnd.ms-excel");

It might be broken in between.
Post your database record and your current excel.

i cannot upload excel file here , i inserted some records to my server ,so sending exported output of excel in jpg formet and
query result

Change Line no. 40 to

header("Content-Type: application/vnd.ms-excel");

i did this but no result , same thing happing....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.