SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict chartahir's Avatar
    Join Date
    Oct 2006
    Location
    Karachi, Pakistan
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Download the query result ?

    I want to download a query result in an Excel file format,
    I can create an excel format file. but i want to work like that:
    as the user clicks on the button/link the generte a file and give user the option to save it on his/her system.

    I can create file but how to download ?
    chartahir

  2. #2
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,000
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    you will need something like this:
    PHP Code:
    header("Element Type: HTTPHeader");
    header("Content-Type: application/vnd.ms-excel");
    header("Content-Disposition: attachment; filename=file_name.csv");
    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: private");

    @
    readfile("path_to_the_file"); 
    -- Jelena --

  3. #3
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
            $filename "ip_pdf.xls";
            
    header('Content-type: application/vnd.ms-excel');
            
    header('Content-Disposition: attachment; filename="' $filename '"');
            
    readfile($filename);
            exit(); 
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  4. #4
    SitePoint Addict chartahir's Avatar
    Join Date
    Oct 2006
    Location
    Karachi, Pakistan
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks.
    chartahir


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •