Nodral Posted October 27, 2011 Share Posted October 27, 2011 Hi I have an array which pull data from a DB (which I didn't create nor can modify) I need to be able to export it to an excel sheet with the data in a specified order. how do I do this? eg run sql queries and end up with array which would be [0] - a [1] - b [2] - c [3] - d [4] - e how would I be able to specify the order eg d , a, c, e, b. to match it up with the column headers on the excel sheet? To make it more of a challenge, I can't amend the column headers either. I can only manipulate the array. I will be pulling multiple arrays out and not all have all the value is them!!! Deep Deep Joy!!! Quote Link to comment https://forums.phpfreaks.com/topic/249916-ordering-array/ Share on other sites More sharing options...
freelance84 Posted October 27, 2011 Share Posted October 27, 2011 Essentailly you need to get your php script to output a CSV file. You can then import this csv file into open office calc or some less worthy spreadsheet program and all the values will be in there own cell accordingly. implode the arrays with a comma and write each line to a file from php http://www.tizag.com/phpT/filewrite.php You haven't given any code to look at though so... Quote Link to comment https://forums.phpfreaks.com/topic/249916-ordering-array/#findComment-1282776 Share on other sites More sharing options...
xyph Posted October 27, 2011 Share Posted October 27, 2011 Be more specific in your example. Where are you getting the column headers from? How is that order determined? Etc. Quote Link to comment https://forums.phpfreaks.com/topic/249916-ordering-array/#findComment-1282835 Share on other sites More sharing options...
Nodral Posted October 28, 2011 Author Share Posted October 28, 2011 I've not posted any code as I haven't got any yet. I just need a pseudo-code theory on how to do this. I have 2 DB tables One is the field names and information about them, the other is the content. I pull an array from the field table which gives me the headings then pull several arrays from the content table which correspond to each individual entry. (against the field names), however the order in which the data comes out of the DB tables into the arrays is not the correct order for the output file. Quote Link to comment https://forums.phpfreaks.com/topic/249916-ordering-array/#findComment-1282913 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.