Jump to content

[SOLVED] excel output problem


dennismonsewicz

Recommended Posts

Code:

 

$who_qry = mysql_query("SELECT * FROM has_had_projects")or die(mysql_error()); 
	$field = mysql_num_fields($who_qry);
	while($row = mysql_fetch_assoc($who_qry)) {
		for($i = 3; $i < $field; $i++) {
			$names = mysql_field_name($who_qry, $i);
			$numbers = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0);         
			$title[] = str_replace($numbers, '', $names);
		}                  
	}

	$excel=new ExcelWriter();
	foreach ($title as $t)
	{
		$excel->writeLine($t); 
	}
	$excel->send('has_had_projects');

 

When I run the code and download the file the spreadsheet is empty :( any ideas?

Link to comment
https://forums.phpfreaks.com/topic/128404-solved-excel-output-problem/
Share on other sites

problem solved!

 

updated working code:

 

$who_qry = mysql_query("SELECT * FROM has_had_projects")or die(mysql_error()); 
	$field = mysql_num_fields($who_qry);
	while($row = mysql_fetch_assoc($who_qry)) {
		for($i = 3; $i < $field; $i++) {
			$names = mysql_field_name($who_qry, $i);
			$numbers = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0);         
			$title[] = str_replace($numbers, '', $names);
		}                  
	}

	$excel=new ExcelWriter();
	$excel->writeLine($title);
	$excel->send('has_had_projects');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.