errors after downloading a .csv file from php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Justin

    #1

    errors after downloading a .csv file from php

    Hi,
    i created a button for my user to download their datas (.csv).
    everything goes well but after u save/download the file. the website
    seems to stop working.

    i got two frames, the left frame is a list of menus for the users such
    as add records, view records, logout etc. the right(main) frame are the
    contents of what the had selected. For example: the users can click on
    the "View Records" function on the left, then the main frame will show
    3 buttons: "View all" "Search" "Download". if they click download and
    save the file. the left frame doesn react if the user try to click add
    record or other func. But if the user click cancel when the dialog box
    which ask them to download appears, everything goes back to normal. Or
    after downloading, if they click "View all" "Search" it also goes back
    to normal. so wat's wrong? below is the coding:

    $a=<<<A
    <form action="" method="post">
    <input type="submit" name="download" value="Download "> Click here to
    download the data
    </form>
    A;

    if(isset($_POST['download']))
    {
    header("Content-type: text/csv");
    header("Content-Disposition: attachment; filename=data.c sv");
    print ("field1,field2 ,field3")."\n";
    $query = "SELECT * FROM data";
    $result = mysql_query($qu ery);
    while($row = mysql_fetch_row ($result)){
    print implode(",", $row)."\n";
    };
    mysql_free_resu lt($result);
    exit();
    }
    echo $a;

  • Justin

    #2
    Re: errors after downloading a .csv file from php

    by the way, this only occurs in IE6.0, it works perfectly in IE7.0 or
    opera... Thanx...

    Comment

    Working...