i want to allow user to download query data from mySQL server

Discussion in 'MySQL' started by Emiela, Jun 1, 2015.

  1. #1
    Hi, I have a non-profit website that I've developed with PHP. I'm trying to make the logged in users can output letters in Word with selected data from a query in MySQL. I've tried to use PHPWord, the letters outputted with no data in the letters. Also I tried used PHP COM, but Hostforlife won't let me restart the server because it is shared.
    Lastly I wrote a SELECT query with INTO OUTFILE '$file' to create a CSV which the users could download and use to merge into Word, but because the database user does not have FILE access, it produces this error:

    Error: Access denied for user 'blabla'@'localhost' (using password: YES)

    I think Hostforlife will not allow FILE privileges on a shared server. So, how can I get around this. Somehow I want to be able to at least write the query and download the data. Javascript? jQuery? or Something else? Any of you can help me?

    Thanks in advance :)
     
    Emiela, Jun 1, 2015 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Just write the query in the normal way in PHP, and instead of outputting it to the screen, write it to a file? If PHP doesn't have file-write access, you could probably do a somewhat convoluted work-around by having the content output so that the user can copy it directly, but that's a bit of a hassle.
     
    PoPSiCLe, Jun 1, 2015 IP
  3. MySQL-Tricks

    MySQL-Tricks Greenhorn

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #3
    Here is the solution of your problem.
    Solution 1:
    You can use DOMPDF to make the output of you data into a pdf file. By using dompdf you can convert your html output page to pdf.

    Solution 2:
    You can use phpExcel Library to output your data as a csv file.

    Note*: save your file into root folder or current directory of your php file which generate the pdf or csv file.
     
    MySQL-Tricks, Jun 13, 2015 IP