marina_darkfury Posted February 3, 2011 Share Posted February 3, 2011 Hi, this is my first time here. i am trying to create an xls file from the data i get from mysql. here is the code i tried but i am not able to use it correctly. ob_start(); include('config'); $datacat = mysql_query("SELECT * FROM `leads`") or die(mysql_error()); $name = mysql_fetch_assoc($datacat); $line1="Industry,Company Name,Officials Name,Job Title,Country,Direct Number Mobile Number,Switch Board Number,E-mail,Executive NamePitch Date,Call Back Date,Comments\t"; while($row = mysql_fetch_array($datacat, MYSQL_ASSOC)) { $line2= $name['industry'].",".$name['company_name'].",".$name['officials_name'].",".$name['job_title'].",".$name['country'].",".$name['direct_number_mobile_number'].",".$name['switch_board_number'].",".$name['email'].",".$name['executive_name'].",".$name['pitch_date'].",".$name['call_back_date'].",".$name['comment']."\t"."\n"; } $data="$line1\n$line2\n"; header("Content-type: application/x-msdownload"); header("Content-Disposition: attachment; filename=extraction.xls"); header("Pragma: no-cache"); header("Expires: 0"); print "$header\n$data"; i get my webpage title in the top of xls file and all the fields in xls file are separated by commas, whereas i want them to be in proper tables. Help would be much appreciated. Link to comment https://forums.phpfreaks.com/topic/226619-problem-exporting-php-data-to-excel-file/ Share on other sites More sharing options...
marina_darkfury Posted February 3, 2011 Author Share Posted February 3, 2011 ok now when i am using WHILE loop i am not able to get anything from $line2 Link to comment https://forums.phpfreaks.com/topic/226619-problem-exporting-php-data-to-excel-file/#findComment-1169624 Share on other sites More sharing options...
marina_darkfury Posted February 4, 2011 Author Share Posted February 4, 2011 any help? Link to comment https://forums.phpfreaks.com/topic/226619-problem-exporting-php-data-to-excel-file/#findComment-1169724 Share on other sites More sharing options...
BlueSkyIS Posted February 4, 2011 Share Posted February 4, 2011 this line doesn't do anything useful. delete it: $name = mysql_fetch_assoc($datacat); // DELETE THIS then switch while($row to while($name Link to comment https://forums.phpfreaks.com/topic/226619-problem-exporting-php-data-to-excel-file/#findComment-1169836 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.