Help with sending data to Excel

Hello,

I have a script that runs a query and places the result in excel query.  This work fine.  I need to take this a step further.  When displaying this data directly on to a web page I parse the data so that it only displays part of the information.

Here is the code I have to generate the excel file:

export = mysql_query($query_rs_ssip_ongoing);
$fields = mysql_num_fields($export);

for ($i = 0; $i < $fields; $i++) {
    $header .= mysql_field_name($export, $i) . "\t";
}

while($row = mysql_fetch_row($export)) {
    $line = '';
    foreach($row as $value) {                                            
        if ((!isset($value)) OR ($value == "")) {
            $value = "\t";
        } else {
            $value = str_replace('"', '""', $value);
            $value = '"' . $value . '"' . "\t";
        }
        $line .= $value;
    }
    $data .= trim($line)."\n";
}
$data = str_replace("\r","",$data);

if ($data == "") {
    $data = "\n(0) Records Found!\n";                        
}

header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=extraction.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";

------------------------------------------------

and here is the code that I use which parses the infromation when displayed on the webpage:

      <?php
                        $text1 = $row_rs_ssip_ongoing['Subject'];
                        $start1 = strpos( $text1, ">" );
                        $ends1 = strpos( $text1, "#" );
                        $eng = substr( $text1, $start1+1, ($ends1-$start1-1) );
                        echo $eng;
                        ?>

What I need to do is merge these two so that the excel output is the same as the information displayed on the website.

Any help appreciated.
andyw27Asked:
Who is Participating?
 
Beverley PortlockConnect With a Mentor Commented:
I'm confused.

When you're displaying the spreadsheet you can't see the webpage because Excel is open in the browser so you can't see both.

Secondly, since you are apparently running exactly the same query the results should be identical. In what way do they differ?
0
 
andyw27Author Commented:

The spreadsheet downloads to the users machine.

They differ because the Excel query returns everything whereas the web page breaks down the content.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.