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 9145873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:37:16+00:00 2026-06-17T10:37:16+00:00

How can I incorporate my loop below to be exported as a CSV? <?php

  • 0

How can I incorporate my loop below to be exported as a CSV?

<?php $answers = new WP_Query(array('cat' => 25, 'order' => 'DESC')); ?>
<table width="100%" border="1" cellspacing="1" cellpadding="1">
      <tr>
        <td valign="top">Name</td>
        <td valign="top">Submission/production title</td>
        <td valign="top">Performance space</td> 
      </tr>
<?php if ($answers->have_posts()) : while ($answers->have_posts()) : $answers->the_post(); ?>   
      <tr>
        <td><?php echo the_title(); ?></td>
        <td><?php echo the_field('submit_submission_production_title'); ?></td>
        <td><?php echo the_field('submit_performance_space'); ?></td>  
      </tr>
   <?php endwhile; ?> 
    </table>                    
<?php endif; ?>

How can I integrate this with fputcsv?

<?php
$list = array (
    'aaa,bbb,ccc,dddd',
    '123,456,789',
    '"aaa","bbb"'
);

$fp = fopen('file.csv', 'w');

foreach ($list as $line) {
    fputcsv($fp, split(',', $line), ',', '&quot;');
}
fclose($fp);
?>
  • 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-17T10:37:18+00:00Added an answer on June 17, 2026 at 10:37 am

    First, the_title and the_field* are functions that do echo by themselves, you don’t need echo the_title().

    * Assuming that this is from Advanced Custom Fields.

    Just build an array, like:

    $answers = new WP_Query( array('cat' => 25, 'order' => 'DESC') ); 
    if ( $answers->have_posts() ) {
        $list = array( 'Name,Submission/production title,Performance space' );
        while ( $answers->have_posts() ) {
            $title = get_the_title();
            $field1 = get_field('submit_submission_production_title');
            $field2 = get_field('submit_performance_space');
            $list[] = $title . ',' . $field1 . ',' . $field2;
    
            // IF ENCLOSING DOUBLE QUOTES ARE NEEDED
            // $list[] = '"' . $title . '","' . $field1 . '","' . $field2 . '"';
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I order my users in the database, so I don't have to say
Can I be sure about the order in a Python dictionary? The function op.GetTangent(id)
I have setup a simple while loop which returns all images in a table
i was wondering whether i can incorporate wordpress blog into a facebook application so
Picture this: you are creating a little module that people can incorporate into their
I'm trying to modify the CakePHP bake script so that I can incorporate saving
Is there anyway I can incorporate a pretty large text file (about 700KBs) into
I'm seeking a library, or bit of code I can incorporate into a Cocoa
We have a few Tcl/Tk scripts (because a GUI we use can incorporate macros
I wonder if someone can help i am trying to incorporate a live search

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.