I need to create export to excel and export to pdf option for some of my mysql queries and provide it to the user.
But also, the user needs to view the query results on my website too.
So, in this case, code redundancy occurs , as I have to create three php code files:
One to let the user view the query results directly on my website , and,
Other one to let the user export the same query results to Excel ,and ,
last one to let the user export the same query results to PDF
All the three files are having the same code, only the difference being the way of sending the data to excel or to pdf.
How do I eradicate this code duplicacy , Is there some way using which I could have only one file and use it for all purposes , to view , to export to pdf and to export to excel too.
Originally asked by: sqlchild on Stack Overflow


Answers