<?php
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=extraction.csv");
header("Pragma: no-cache");
header("Expires: 0");
require_once( "db.php" );
$query = "SELECT * FROM name ORDER BY last";
$result = mysql_query($query) or die(mysql_error());
echo "ID,First,Middle,Last,Email\r\n"; //header
while($row = mysql_fetch_array($result)){
echo "\"$row[id]\",\"$row[first]\",\"$row[middle]\",\"$row[last]\",\"$row[email]\"\r\n"; //data
}
?>
csshacker 0 Newbie Poster
Recommended Answers
Jump to Post<?php $filename ="excelreport.csv"; $contents = "testdata1;testdata2;testdata3; \n"; header('Content-type: application/ms-excel'); header('Content-Disposition: attachment; filename='.$filename); echo $contents; ?>
I had given a similar example in another thread. Well, csv or excel, the procedure is the same.
Where did this man go? He is missing (together with kkeith and other longtime phpers)
Jump to PostYou've necroposted to this thread. Your request is not related to creating a csv. Please start a new thread if you can't find a related thread from the Daniweb search.
You probably won't find an exact match as most files are uploaded to the server in the same ways. 2 …
All 8 Replies
nav33n 472 Purple hazed! Team Colleague Featured Poster
csshacker 0 Newbie Poster
suhnako 0 Newbie Poster
rpv_sen 59 Junior Poster
Stefano Mtangoo 455 Senior Poster
suhnako 0 Newbie Poster
kundan.ignou 0 Newbie Poster

diafol
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.