dennismonsewicz Posted October 10, 2008 Share Posted October 10, 2008 I have the folllowing code: <?php $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, '', ucwords($names . ',')); } } $excel=new ExcelWriter(); $explode = explode(',', $title); for($i = 0; $i < count($explode); $i++) { $pieces .= $explode[$i] . ','; } $trim = trim($pieces, ','); $myArr=array($trim); $excel->writeLine($myArr); ?> When it writes to the excel spreadsheet is placing all of the row names on one line i am guessing because the names are stored as one var instead of separate pieces of the array? Any ideas? Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted October 10, 2008 Author Share Posted October 10, 2008 bump Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 10, 2008 Share Posted October 10, 2008 What is this code supposed to do? Ken Quote Link to comment Share on other sites More sharing options...
Barand Posted October 10, 2008 Share Posted October 10, 2008 why all the moving from comma delimited strings to arrays and back again? And did you really want the column names repeating for every row? Anyway, try $who_qry = mysql_query ("SELECT * FROM user"); $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, '', ucwords($names . ',')); } } $excel=new ExcelWriter(); foreach ($title as $t) { $excel->writeLine($t); } Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted October 10, 2008 Author Share Posted October 10, 2008 now its not even printing the names updated 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, '', ucwords($names . ',')); } } $excel=new ExcelWriter(); foreach ($title as $t) { $excel->writeLine($t); } Quote Link to comment Share on other sites More sharing options...
Barand Posted October 10, 2008 Share Posted October 10, 2008 add echo statement $excel=new ExcelWriter(); foreach ($title as $t) { $excel->writeLine($t); echo "$t<br/>"; // print field name } I don't know your ExcelWriter class but does it need a filename? 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.