Jump to content

problem while exporting phpt out put to excel


Laxmis

Recommended Posts

hello I wrote a php code which will get the records from database and save them in excel.

 

      <?php

 

        $t = strtotime($date1);

        $t1 = strtotime($date2);

        $t2 = $t1 - $t;

        $t3 = floor($t2 /60/60/24);

 

        $j = 0;

        while ($j <= $t3 ) {

            if ($j == 0)

          { $t = $t - 86400; }

            $t = $t + 86400;

            $today = date('Y-m-d',$t);

                    mysql_select_db("reporting", $connect);

                      $result1 = mysql_query("SELECT * from report where date = '$today' ");

                      $row1 = mysql_fetch_assoc($result1);

 

            ?><tr><?php

            foreach($row1 as $k=>$v){

              ?>

                <td><?php echo $v;

                          $op1 = $row[$v];

                          ?></td>

                <?php

                    }

                    ?></tr><?php

                $j++;

                }

 

 

            ?>

        </table>

        <body>

            </html>

 

 

<?php mysql_close($connect);

 

  header("Content-type: application/vnd.ms-excel");

  header('Content-disposition: attachment; filename = "report" ');

 

  exit;  ?>

 

Problem is I am able to retrieve only 2 rows to excel file. If the number of rows are more than 2 it displays a table. can any one help me

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.