Hello there,
i have an app that i need to be able to publish a link to download a
csv file.
i know that i can use php to make the file, but how to i link to it
through php.
like if i have an html file that has a link in it like this
<a href="somedata. csv">here be data</a>
or would i make that a .php file that would generate a csv ?
the data will come from MySQL.
any ideas?
thanks 5 5802
nephish wrote:
Hello there,
i have an app that i need to be able to publish a link to download a
csv file.
i know that i can use php to make the file, but how to i link to it
through php.
like if i have an html file that has a link in it like this
<a href="somedata. csv">here be data</a>
or would i make that a .php file that would generate a csv ?
the data will come from MySQL.
any ideas?
By me the best choice is to have page with links as php page and have other
php page for generating and sending csv file direct to browser.
download.php
-------------------
<html><body.. ..
<?php
# link for csv where mysql query contain eg. "... WHERE id=12345"
echo "<a href=\"sendcsv. php?id=12345\>h ere be data</a>\n";
?>
</body></html>
sendcsv.php
-----------------
<?php
$link = mysql_connect(" localhost", "user, "password") or die(mysql_error ());
mysql_select_db ("mydb") or die(mysql_error ());
$id = $_GET["id"]*1; # multiply by 1 preempt sql injection
$query = "SELECT * FROM mytable WHERE id=$id";
$result = mysql_query($qu ery);
echo "Content-Type: application/csv\n",
"Content-Disposition: filename=\"csv_ data.csv\"\n\n" ;
while ($row = mysql_fetch_arr ay($result, MYSQL_ASSOC))
{
echo $row["field1"], ';', $row["field2"], ';' ...."\n";
}
mysql_free_resu lt($result);
mysql_close($li nk);
?>
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Petr Vileta wrote:
nephish wrote:
Hello there,
i have an app that i need to be able to publish a link to download a
csv file.
i know that i can use php to make the file, but how to i link to it
through php.
like if i have an html file that has a link in it like this
<a href="somedata. csv">here be data</a>
or would i make that a .php file that would generate a csv ?
the data will come from MySQL.
any ideas?
By me the best choice is to have page with links as php page and have other
php page for generating and sending csv file direct to browser.
download.php
-------------------
<html><body.. ..
<?php
# link for csv where mysql query contain eg. "... WHERE id=12345"
echo "<a href=\"sendcsv. php?id=12345\>h ere be data</a>\n";
?>
</body></html>
sendcsv.php
-----------------
<?php
$link = mysql_connect(" localhost", "user, "password") or die(mysql_error ());
mysql_select_db ("mydb") or die(mysql_error ());
$id = $_GET["id"]*1; # multiply by 1 preempt sql injection
$query = "SELECT * FROM mytable WHERE id=$id";
$result = mysql_query($qu ery);
echo "Content-Type: application/csv\n",
"Content-Disposition: filename=\"csv_ data.csv\"\n\n" ;
while ($row = mysql_fetch_arr ay($result, MYSQL_ASSOC))
{
echo $row["field1"], ';', $row["field2"], ';' ...."\n";
}
mysql_free_resu lt($result);
mysql_close($li nk);
?>
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
cool, thanks a lot !
-sk
PHP to generate the CSV is probably easiest:
<?php header("Content-Type", "text/csv");
// code spewing CSV here
?>
nephish wrote:
Hello there,
i have an app that i need to be able to publish a link to download a
csv file.
i know that i can use php to make the file, but how to i link to it
through php.
like if i have an html file that has a link in it like this
<a href="somedata. csv">here be data</a>
or would i make that a .php file that would generate a csv ?
the data will come from MySQL.
any ideas?
thanks
James McIninch wrote:
PHP to generate the CSV is probably easiest:
<?php header("Content-Type", "text/csv");
// code spewing CSV here
?>
nephish wrote:
Hello there,
i have an app that i need to be able to publish a link to download a
csv file.
i know that i can use php to make the file, but how to i link to it
through php.
like if i have an html file that has a link in it like this
<a href="somedata. csv">here be data</a>
or would i make that a .php file that would generate a csv ?
the data will come from MySQL.
any ideas?
thanks
i like the code spewing csv bit. But the filename will be a .php, right
? Will the browser the client uses recognize that it is producing a csv
for them to download? You know, with the little [save as] dialog?
thanks
shawn
James McIninch wrote:
PHP to generate the CSV is probably easiest:
<?php header("Content-Type", "text/csv");
// code spewing CSV here
>>
What is the right type "text/csv" or "applicatio n/csv" ? For me work both
but what is right?
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Peivasteh |
last post by:
Hi
Anybody can help who know PHP .
I want you to have look at this site first.
http://www.bigshotmedia.com
How this site use PHP to protect swf files to not download to cashin
temparary folder.
Anybody knows about this how PHP works or what is PHP script.
Thanks
Behzad Peivasteh
|
by: Ted Miller |
last post by:
Hi folks,
I'm looking at moving a large base of C++ code to .Net under tight time
constraints. The code runs in mission-critical environments, and I am
extremely concerned about the loader lock problem and the potential for
deadlocks.
After pouring over the available information, and trying a few experiments,
I am still left with a few questions and issues I hope someone out there can
shed some light on.
|
by: Cheryl Langdon |
last post by:
Hello everyone,
This is my first attempt at getting help in this manner. Please
forgive me if this is an inappropriate request.
I suddenly find myself in urgent need of instruction on how to
communicate with a MySQL database table on a web server, from inside
of my company's Access-VBA application. I know VBA pretty well but
have never before needed to do this HTTP/XML/MySQL type functions.
|
by: satan |
last post by:
I need a help with the program to test the insertion, deletion, search, copyList, and the copy constructor operations for an object in the class UnorderedLinkedList.
These are my classes:
public class UnorderedLinkedList extends LinkedListClass
{
public UnorderedLinkedList()
|
by: satan |
last post by:
I need a help with the program to test the insertion, deletion, search, copyList, and the copy constructor operations for an object in the class UnorderedLinkedList.
These are my classes:
public class UnorderedLinkedList extends LinkedListClass
{
public UnorderedLinkedList()
| |
by: Bruce W. Darby |
last post by:
This will be my very first VB.Net application and it's pretty simple. But
I've got a snag in my syntax somewhere. Was hoping that someone could point
me in the right direction.
The history:
My work involves creating custom packages of our software product for golf
courses that purchase our software. The course data is kept as a back up in
the event the course needs us to replace their custom files. Each course has
a folder of it's own...
|
by: mike |
last post by:
I help manage a large web site, one that has over
600 html pages... It's a reference site for ham radio
folks and as an example, one page indexes over
1.8 gb of on-line PDF documents.
The site is structured as an upside-down tree, and
(if I remember correctly) never more than 4 levels.
The site basically grew (like the creeping black blob) ...
all the pages were created in Notepad over the last
|
by: Neil Gould |
last post by:
Hi all,
Thanks for the suggestions for our club's initial bulkmail sending
routines. I did read up on the use of ASP vs. a separate COM app such as
ASPEmail, and determined that for our club's purposes the ASP code that
loops through the data and sends individual messages vs. BCC performs
adequately for simple messaging.
The next phase is to email the club's newsletter, which is in PDF format,
and I've run into the problem that CDO...
|
by: Bob Bedford |
last post by:
I've to build a website where the customer can buy an image. I'm thinking in
the 2 ways to let people get those images: receive them by Email or send
them an image link wich validity is limited in time.
The second may help me to know if an image has been downloaded and how many
times.
How to build such download link ?
The informations I'd like is the userid, the datetime limit and the
imagefile, off course everything must be encrypted...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |