![]() |
|
|
|
Insert Tag Line HERE.....
|
MySql to .xls php script help
I have a MySql database that I need to be able to send to an .xls file that has multiple rows and columns. I would like to be able to generate a php script that will send a copy of the database to excel preferably from a onclick function so as the user can simply click a button to do it. I've looked at a few codes online, but everyone has a completely different way of doing it, so wondering if anybody here has a preferred way.
Thanks! Marc |
||
![]() |
|
The Unsettler
|
phpMyAdmin will export to CSV pretty much one click.
But users need access to it. Set permissions properly and it should be ok. Is the export an entire DB or the results of a query?
__________________
"I want my two dollars" "Goodbye and thanks for the fish" "Proud Member and Supporter of the YWL" "Brandon Won" |
||
![]() |
|
Insert Tag Line HERE.....
|
I setup up the database through phpmyadmin but the users will only have access to a website. Right now, I have setup a query based on a gui format where it can be searched and information entered by the users but also want an .xls file that I will use on google docs to share with other board members. I need it to be updated once a week or so hopefully from a oneclick button from one of the users. It will be the entire database each time, unless their is a way to update on the last few lines and export that to be added to the existing .xls?
In a nutshell, this is a database in which we allow a few users to enter penalties (local hockey club) into that can be later searched by the league officers and they want a local copy in an .xls format. So the users entering simply would have no clue or permissions to the database for anything else except data entry. |
||
![]() |
|
Registered
Join Date: Mar 2003
Posts: 10,317
|
Something like this should work. Took it from an existing setup I was using, removed the logic that specified some control over which rows were sent so it sends everything matching your query. Note that mysql_* functions are on the way out and should be replaced with PDO object calls instead.... If you can send me a mysql_dump of the table and the query you'd want to use (assuming you just don't want everything) and I'll do it up and debug it, then send you back the known-good PHP. Email it to me - sj at gruv dot org
PHP Code:
__________________
“IN MY EXPERIENCE, SUSAN, WITHIN THEIR HEADS TOO MANY HUMANS SPEND A LOT OF TIME IN THE MIDDLE OF WARS THAT HAPPENED CENTURIES AGO.” Last edited by id10t; 07-10-2014 at 06:32 PM.. |
||
![]() |
|
Insert Tag Line HERE.....
|
Sent you an email.. Thanks!
|
||
![]() |
|
Registered
Join Date: Mar 2003
Posts: 10,317
|
Replied
![]()
__________________
“IN MY EXPERIENCE, SUSAN, WITHIN THEIR HEADS TOO MANY HUMANS SPEND A LOT OF TIME IN THE MIDDLE OF WARS THAT HAPPENED CENTURIES AGO.” |
||
![]() |
|
![]() |
Insert Tag Line HERE.....
|
THANK YOU STEVE!! This board Rocks!!!
|
||
![]() |
|
Registered
Join Date: Mar 2003
Posts: 10,317
|
Code had a minor bug in it (extra end parens left over from a removed print function), I've fixed the copy above. Also added some variable declaration and comments at the top since that is what rattlsnak had questions about.
Licensed under GPLv2 - use, change, share, enjoy
__________________
“IN MY EXPERIENCE, SUSAN, WITHIN THEIR HEADS TOO MANY HUMANS SPEND A LOT OF TIME IN THE MIDDLE OF WARS THAT HAPPENED CENTURIES AGO.” |
||
![]() |
|