I have two files like below.
What I'm trying to do is, I want to fetch the second file content in first file, and then export it to xls.
What is the problem with the below code.
My intension is to - read a second php file using first php file, and then excel export that content into .xls in C:/myfiles/test.xls
index.php
<?php
$read_file = readfile("my_export_file.php");
$file = 'test.xls';
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo $read_file;
?>
my_export_file.php
<script type="text/javascript"> my javascript content</script>
<?php
include 'db.php';
$my_query = "mysql query to get the table content";
?>
<table>
<tr><td>.. mysql row content ..</td><td>.. mysql row content ..</td></tr>
<tr><td>.. mysql row content ..</td><td>.. mysql row content ..</td></tr>
<tr><td>.. mysql row content ..</td><td>.. mysql row content ..</td></tr>
</table>
Could someone help me to get this done.
Thanks in advance.
Regards, Kimz
Found out solution, try this:
index.php
Hope this help you.
In your export.php file you should fetch result & create table with results. Then just echo that table as given in example.
my_export_file.php
index.php