|
Posted by Justin on 05/29/06 06:22
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.csv");
print ("field1,field2,field3")."\n";
$query = "SELECT * FROM data";
$result = mysql_query($query);
while($row = mysql_fetch_row($result)){
print implode(",", $row)."\n";
};
mysql_free_result($result);
exit();
}
echo $a;
Navigation:
[Reply to this message]
|