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

Link to comment
Share on other sites

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.