how can i view data in the excel sheet
Moderator: General Moderators
- softsolvers
- Forum Commoner
- Posts: 75
- Joined: Fri Feb 13, 2004 4:26 am
- Location: India
how can i view data in the excel sheet
hello friends i want to view my data in the excell sheet which will be fetched by the mysql.could you help me
- softsolvers
- Forum Commoner
- Posts: 75
- Joined: Fri Feb 13, 2004 4:26 am
- Location: India
Plz help on this matter
hello friends,
i want to view the data fetched from the mysql data base o the excel sheet can u suggest me that what should i do.
i want to view the data fetched from the mysql data base o the excel sheet can u suggest me that what should i do.
And once you have the MySQL stuff down:
http://builder.com.com/5100-31-5077752.html
http://builder.com.com/5100-31-5077752.html
Suppose you're running an intranet Web site that has data stored in Microsoft SQL Server, and your users need that data in Excel format. You can have PHP run the necessary SQL queries and format the output, then use COM to open Excel, dump the data stream into it, and save the file on the user's desktop.
- Make a page that fetches all the data by line in CSV format.
- dont forget to add the right header :
Here is a code I wrote a moment ago (in French) PHP:
Did I understand correctly ?
- dont forget to add the right header :
Here is a code I wrote a moment ago (in French) PHP:
Code: Select all
<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=table.csv");
header("Content-Transfer-Encoding: binary");
include ("Connections/localhost.php"); //contains all connection params
$connection = mysql_connect ("$hostname_localhost", "$username_localhost", "$password_localhost");
$query = "SELECT * FROM sirca_concours";
$result= mysql_db_query ("$database_localhost", $query);
$numOfRows = mysql_num_rows($result);
for ($i = 0; $i < $numOfRows; $i++){
$civilite = mysql_result ($result, $i, civilite);
$prenom = mysql_result ($result, $i, prenom);
$nom = mysql_result ($result, $i, nom);
$adresse1 = mysql_result ($result, $i, adresse1);
$adresse2 = mysql_result ($result, $i, adresse2);
$ville = mysql_result ($result, $i, ville);
$npa = mysql_result ($result, $i, npa);
$pays = mysql_result ($result, $i, pays);
$email = mysql_result ($result, $i, email);
print ""$civilite","$prenom","$nom","$adresse1","$adresse2","$ville","$npa","$pays","$email"\n";
}
?>- softsolvers
- Forum Commoner
- Posts: 75
- Joined: Fri Feb 13, 2004 4:26 am
- Location: India
dispalying on excel sheety
hello friends,
can you tell me what these header exactly stand for and what should be the actual code in that header if i am running code on local machine
looking f/w for result
can you tell me what these header exactly stand for and what should be the actual code in that header if i am running code on local machine
looking f/w for result
- softsolvers
- Forum Commoner
- Posts: 75
- Joined: Fri Feb 13, 2004 4:26 am
- Location: India
I don't quite get your question. These headers tell the browser that a csv document is being sent. So in fact the main page must simply link to this one. When the user clicks the link he'll get a" do you want to open or save?" box.
This works locally or on a remote machine.
If my answer is beside the point be more specific.
Evil
This works locally or on a remote machine.
If my answer is beside the point be more specific.
Evil
- softsolvers
- Forum Commoner
- Posts: 75
- Joined: Fri Feb 13, 2004 4:26 am
- Location: India
how can i take the drop down menu's value on the same page
hello friends
i want to take the value of the drop down menu on the same page means if user has selected his choice and the corresponding action has perform according to the selection.
i want to take the value of the drop down menu on the same page means if user has selected his choice and the corresponding action has perform according to the selection.
- softsolvers
- Forum Commoner
- Posts: 75
- Joined: Fri Feb 13, 2004 4:26 am
- Location: India
- softsolvers
- Forum Commoner
- Posts: 75
- Joined: Fri Feb 13, 2004 4:26 am
- Location: India
-
Sinemacula
- Forum Contributor
- Posts: 110
- Joined: Sat Feb 08, 2003 2:36 am
- Location: San Jose, CA
An additional wrinkle...
I'm trying to do something similar, and I follow the script you've posted... but I've got another piece to what I'm trying which leaves me unsure how to proceed...
I want to be able to choose between several tables, which one I want to download as a csv file... (I've figured this part out, using a variable for the table name)... the catch is that each table has a different number of (and names of) fields, so I can't use the fieldnames to create the output. Is there a way to write the script so that it will figure that out on it's own?
Thanks,
Scott
I want to be able to choose between several tables, which one I want to download as a csv file... (I've figured this part out, using a variable for the table name)... the catch is that each table has a different number of (and names of) fields, so I can't use the fieldnames to create the output. Is there a way to write the script so that it will figure that out on it's own?
Thanks,
Scott