Jump to content

Recommended Posts

Hi @LL

 

 

I want export table in php to excell file.

 

Here is for example link:

 

https://mydomain.local/something.php?operation=hyperlinknametosomething2.php&table1.field1=111&table1.field2=123&table1.field3

 

and this display 5 fields with maximum of 10 rows.

 

 

Is there a way to export to excel file using above link?

Our framework use sql & php.

It would be great if this could be a hyperlink with text: "click to save"

or a button?

 

 

if need more info let me know.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/130752-export-table-to-excel-in-php/
Share on other sites

Easiest method is to export your data as a CSV file, which can be loaded into Excel and other spreadsheet programs.

 

CSV stands for 'comma spaced variables' because it contains your data, delimited with commas (usually) like this

 

row#,field1,field2,field3
"1","value1","value2","value3"

 

Here is a sample of how to open and write to a CSV file:

 

$myFile = "your_list.csv";

$fh = fopen($myFile, 'w') or die("can't open file");

fwrite($fh, $field1 . ", " . $field2 . ", " . $field3 .  "\n");

 

but I don't want to specify fields.

I need to use the link above

 

Here is a sample of how to open and write to a CSV file:

 

$myFile = "your_list.csv";

$fh = fopen($myFile, 'w') or die("can't open file");

fwrite($fh, $field1 . ", " . $field2 . ", " . $field3 .  "\n");

 

but I don't want to specify fields.

I need to use the link above

 

 

Can you explain exactly what you're trying to accomplish?

 

My guess is that you're taking the fields from the URL and using them to query something from your database.  Then place the results from that query in the CSV file...?

Actually, CSV stands for 'comma-separated values'.

 

Makes more sense... I'm not native to English so I confuse TLAs from time to time. You know that SQL is for Standardised Questioning Language? ;)

 

SQL does not stand for that, it stands for 'Structured Query Language'.

 

yes,

 

link above gives a small table of listing from our database.

I want to export that listing to excel file using this link if possible.

 

I know that I can use queries and manually typing fields but this is too much hassle.

 

is there a way that we can use "header" function to or something better to export everything that

this link displays?

https://mydomain.local/something.php?operation=hyperlinknametosomething2.php&table1.field1=111&table1.field2=123&table1.field3

 

thanks

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.