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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
marina_darkfury Posted February 4, 2011 Author Share Posted February 4, 2011 any help? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.