Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8395587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:20:20+00:00 2026-06-09T20:20:20+00:00

I have a code here to generate an excel file if the submit button

  • 0

I have a code here to generate an excel file if the submit button is clicked. The file is populated with data from mysql and of course is based from a mysql query. Here it is:

<?php
require("aacfs.php");

header("Content-type: application/ms-excel");
header("Content-Disposition: attachment; filename=Reservation Summary_sortbydate.xls");
header("Pragma: no-cache");
header("Expires: 0");

$head1="Ayala Aviation Corporation";
$head2="RESERVATION SUMMARY";
$head3="For the period ___________";


$heads="$head1\n$head2\n$head3\n";

$query = "select bdate as 'Date', cliename as 'Client', grpcode as 'Group Code', bperson as 'Contact', reservno as 'Reservation No.', acode as 'Aircraft', fdate as 'Flight Date', itinerary as 'Itinerary', etd as 'ETD', eta as 'ETA', pname as 'Passengers', status as 'Status', cutoff as 'Confirmation Cut-off', adminid as 'Reserved by' from reservation order by bdate";

$result = mysql_query($query);
if($result) {
    $count = mysql_num_rows($result);
   for($i=0; $i<$count; $i++) {
   for ($i = 0; $i < mysql_num_fields($result); $i++) 
    { 
    $schema_insert_rows.=mysql_field_name($result,$i) . "\t"; 
    } 
    $schema_insert_rows.="\n"; 

        while($row = mysql_fetch_row($result)) {
            $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";
        }
    }
    print mb_convert_encoding("$heads\n$schema_insert_rows\n$data", 'UTF-16LE', 'UTF-8');
} else die(mysql_error());
?>

It takes long for it to execute and when it is finally downloaded on my computer, the file displays an error message: ‘Maximum execution time of 60 seconds exceeded’. I tried setting the time limit like this: set_time_limit(0) but it still take a long time before I can get to download the file and when I opened the downloaded file, another error displays again on the file itself: ‘Allowed memory size of 134217728 bytes exhausted (tried to allocate 133693422 bytes)’

I have this exact code but different mysql_query running on another php file so I’m really frustated as to why this doesn’t work. I have this working smoothly the other day but when I checked it again today, it shows this error. What am I doing wrong? Any help would be appreciated. Thank you in advance! GOD bless!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:20:22+00:00Added an answer on June 9, 2026 at 8:20 pm

    Did you try fetching 10 data and see if they have same results or error? I think the data that you are trying to export is kinda a heavy that’s why you encounter the execution timeout.

    Update your query with this.

    $query = "
    select 
        bdate as 'Date', 
        cliename as 'Client', 
        grpcode as 'Group Code', 
        bperson as 'Contact', 
        reservno as 'Reservation No.', 
        acode as 'Aircraft', 
        fdate as 'Flight Date', 
        itinerary as 'Itinerary', 
        etd as 'ETD', 
        eta as 'ETA', 
        pname as 'Passengers', 
        status as 'Status', 
        cutoff as 'Confirmation Cut-off', 
        adminid as 'Reserved by' 
    from 
        reservation 
    group by 
        bdate 
    LIMIT 10";
    

    update your php.ini

         post_max_size = 8M
         default_socket_timeout = 60
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code here printf '$request1 = select * from whatever where this
I have this code here, {foreach from=$cart.cartItems item=item name=cart} <div id=cart2Produkt> <p>{if $item.Product.ID} <a
I have my code here, it works fine from my home, where my user
I have a problem with search box. So here is the code to generate
i have existing code that generates a spreadsheet from excel using OpenXML. It works
I am using Python to generate some data and have some code like this
I'm trying to export data from my models to an excel spreadsheet. I have
I have to generate about 800 excel files from an access database. For the
I have some code that written in php to use for export data from
I have an excel sheet that I am wanting to extract data from and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.