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

  • Home
  • SEARCH
  • 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 6785837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:10:29+00:00 2026-05-26T17:10:29+00:00

I created a web application and I want to add a feature like user

  • 0

I created a web application and I want to add a feature like user can export selected records…

Check Box   Name    Email

            Sumit   sumit@gmail.com
            Karan   karan@gmail.com

I want to export this records into an excel file, but only the selected records should be exported.

Thanks in advance

  • 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-05-26T17:10:30+00:00Added an answer on May 26, 2026 at 5:10 pm

    There’s no need to download external libraries – everything you need for this is already built into PHP.

    Steps:

    1. Do query in php to get the rows you want to output
      You can use SELECT * FROM table WHERE id IN (1,2,...)
    2. Use mysql_fetch_array() or mysql_fetch_assoc() to get the rows one at a time
    3. Use fputcsv() to output them to a file ending in csv – this will properly escape your data

    http://www.php.net/manual/en/function.mysql-fetch-array.php
    http://php.net/manual/en/function.fputcsv.php

    Excel will be able to read the file.

    Override the defaults for fputcsv to use tabs for delimiters and Excel will have an even easier time reading the file. If you use commas (the default) you may need to pick commas as the delimiter on Excel import.

    Here’s a working example assuming you already have rows set up:

    $rows; // predefined
    $filename = 'webdata_' . date('Ymd') . '.csv';
    
    header("Content-Disposition: attachment; filename=\"$filename\"");
    header("Content-Type: application/octet-stream"); 
    // that indicates it is binary so the OS won't mess with the filename
    // should work for all attachments, not just excel
    
    $out = fopen("php://output", 'w');  // write directly to php output, not to a file
    foreach($rows as $row)
    {
      fputcsv($out, $row);
    }
    fclose($out);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my web application I want to log certain user interactions etc, like User
I need to add user roles and permission system into my web application built
I have created a small web application in java. And now I want to
i want to add a javascript File or Function to vb.net application web browser.
I want to create a web application that allows users to sign up, register
I want to create site thumbnails through my web application, so I thought I
I have created a Web Application in asp.net 2.0. which is working fine on
I've created a web application that I've hosted with IIS 7 on a Windows
We have created a web application, using ASP.NET, that allows users to upload documents
I have created a web application using Visualstudio 2008 using C# on my computer.

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.