php - Comments column not showing in csv output file -


i'm web designer , new php , trying fix custom wordpress plugin done developer. there customer survey, , results spit out csv file. of fields spit out except comments boxes.

here php customer survey form.

<div class="form-field-container form-field-comment"> <label class="form-field-label" for="customer-survey-member-comment">comments:</label> <textarea id="customer-survey-member-comment" name="customer_survey[member_comment]"><?php print esc_textarea($survey['member_comment']); ?></textarea> </div> 

i noticed

<?php  function customer_survey_variables() { return array( 

page did not have member_comment listed added 'members' array.

'members' => array(         'ackerley_rose' => 'ackerley, rose',         'bailey_teresa' => 'bailey, teresa',         'behshid_mary' => 'behshid, mary',         'chiang_dudee' => 'chiang, dudee',         'cooper_julie' => 'cooper, julie',         'coppin_ann' => 'coppin, ann',         'daruthayan_beth' => 'daruthayan, beth',         'hernandez_marlon' => 'hernandez, marlon',                   'honchell_mickey' => 'honchell, mickey',         'le_minh' => 'le, minh',         'kelly_michele' => 'kelly, michele',         'medina_danielle' => 'medina, danielle',         'phipps_dan' => 'phipps, dan',         'powers_robert' => 'powers, robert',         'reynolds_lee' => 'reynolds, lee',         'schofield_sunny' => 'schofield, sunny',         'tompson_sara' => 'tompson, sara',         'member_comment' => 'comments - members', 

i able member_comment column, had n/a in it. i'm pretty lost next step create new comments array , add customer_survey_csv results section, without n/a, here

foreach ($results $index => $result) { $ratings = array(     'product' => array_fill_keys(array_keys($variables['products']), 'n/a'),     'service' => array_fill_keys(array_keys($variables['services']), 'n/a'),     'member' => array_fill_keys(array_keys($variables['members']), 'n/a'), ); 

if has guidance or suggestions i'd grateful. thanks.

the code using below.

//the page setting customer survey

<?php foreach ($services $name => $label): ?> <div class="form-field"> <label class="form-field-label"><?php print $label; ?></label> <ul class="form-field-radio"> <li><input type="radio" name="customer_survey[service][<?php print $name; ? >]" value="1" <?php print $survey['service'][$name] == 1 ? 'checked ' : ''; ?>/></li> <li><input type="radio" name="customer_survey[service][<?php print $name; ?>]" value="2" <?php print $survey['service'][$name] == 2 ? 'checked ' : ''; ?>/></li> <li><input type="radio" name="customer_survey[service][<?php print $name; ?>]" value="3" <?php print $survey['service'][$name] == 3 ? 'checked ' : ''; ?>/></li> <li><input type="radio" name="customer_survey[service][<?php print $name; ?>]" value="4" <?php print $survey['service'][$name] == 4 ? 'checked ' : ''; ?>/></li> <li><input type="radio" name="customer_survey[service][<?php print $name; ?>]" value="5" <?php print $survey['service'][$name] == 5 ? 'checked ' : ''; ?>/></li> </ul> </div> <?php endforeach; ?>  <?php foreach ($comments $name => $label): ?> <div class="form-field-container form-field-comment"> <label class="form-field-label" for="customer-survey-service-comment">service comments:</label> <textarea id="customer-survey-service-comment" name="customer_survey[service_comment]"><?php print esc_textarea($survey['service_comment']); ?></textarea> </div> <?php endforeach; ?> </div>  <div class="form-field-container" id="customer-survey-members"> <div class="form-field-container-label form-field"> <label class="form-field-label">staff:</label> <ul class="form-field-radio"> <li>1</li>             <li>2</li>             <li>3</li>             <li>4</li>             <li>5</li>         </ul>     </div>      <?php foreach ($members $name => $label): ?>     <div class="form-field">         <label class="form-field-label"><?php print $label; ?></label>         <ul class="form-field-radio">             <li><input type="radio" name="customer_survey[member][<?php print $name; ?>]" value="1" <?php print $survey['member'][$name] == 1 ? 'checked ' : ''; ?>/></li>             <li><input type="radio" name="customer_survey[member][<?php print $name; ?>]" value="2" <?php print $survey['member'][$name] == 2 ? 'checked ' : ''; ?>/></li>             <li><input type="radio" name="customer_survey[member][<?php print $name; ?>]" value="3" <?php print $survey['member'][$name] == 3 ? 'checked ' : ''; ?>/></li>             <li><input type="radio" name="customer_survey[member][<?php print $name; ?>]" value="4" <?php print $survey['member'][$name] == 4 ? 'checked ' : ''; ?>/></li>             <li><input type="radio" name="customer_survey[member][<?php print $name; ?>]" value="5" <?php print $survey['member'][$name] == 5 ? 'checked ' : ''; ?>/></li>         </ul>     </div>     <?php endforeach; ?>       <div class="form-field-container form-field-comment">         <label class="form-field-label" for="customer-survey-member-comment">comments:</label>         <textarea id="customer-survey-member-comment" name="customer_survey[member_comment]"><?php print esc_textarea($survey['member_comment']); ?></textarea>     </div> 

//the page collecting results , sending them csv page

<?php if (!empty($delete_message)): ?> <div class="customer-survey-delete-message <?php print !empty($deleted_rows) ? 'success' : 'error'; ?>"><?php print $delete_message; ?></div> <?php endif; ?>  <table cellspacing="0" id="customer-survey-product-averages" class="wp-list-table widefat fixed customer-survey-average">  <thead>     <tr>         <th class="customer-survey-average-label">product name</th>         <th class="customer-survey-average-label">average rating</th>     </tr> </thead> <tbody> <?php foreach ($averages['products'] $name => $average): ?> <tr> <td class="customer-survey-average-label"><?php print $variables['products'][$name]; ?></td> <td class="customer-survey-average-value"><?php print is_null($average) ? 'no rating' : $average; ?></td> </tr> <?php endforeach; ?> </tbody> </table>  <table cellspacing="0" id="customer-survey-member-averages" class="wp-list-table widefat fixed customer-survey-average"> <thead>     <tr>         <th class="customer-survey-average-label">staff member name</th>         <th class="customer-survey-average-value">average rating</th>     </tr> </thead> <tbody>     <?php foreach ($averages['members'] $name => $average): ?>     <tr>         <td class="customer-survey-average-label"><?php print $variables['members'][$name]; ?></td>         <td class="customer-survey-average-value"><?php print is_null($average) ? 'no rating' : $average; ?></td>     </tr>     <?php endforeach; ?> </tbody> </table>  <table cellspacing="0" id="customer-survey-service-averages" class="wp-list-table widefat fixed customer-survey-average"> <thead>     <tr>         <th class="customer-survey-average-label">service name</th>         <th class="customer-survey-average-value">average rating</th>     </tr> </thead> <tbody>     <?php foreach ($averages['services'] $name => $average): ?>     <tr>         <td class="customer-survey-average-label"><?php print $variables['services'][$name]; ?></td>         <td class="customer-survey-average-value"><?php print is_null($average) ? 'no rating' : $average; ?></td>     </tr>     <?php endforeach; ?> </tbody> </table>  <hr class="customer-survey-break" />  <form id="customer-survey-result" method="post">  <a href="<?php print plugin_dir_url(__file__) . 'customer_survey_csv.php'; ?>" id="customer-survey-download-csv">download csv</a>  <table cellspacing="0" id="customer-survey-results" class="wp-list-table widefat fixed"> <thead> <tr>         <th class="customer-survey-average-label sortable <?php print $dir . ($sort == 'badge' ? ' sorted' : null); ?>">             <a href="<?php print admin_url('admin.php?' . http_build_query(array(                 'page' => 'customer-survey-results',                 'pagination' => $page,                 'sort' => 'badge',                 'dir' => $sort == 'badge' ? ($dir == 'asc' ? 'desc' : 'asc') : 'asc',             ))); ?>"><span>badge number</span><span class="sorting-indicator"></span></a>         </th>         <th class="customer-survey-average-label sortable <?php print $dir . ($sort == 'email' ? ' sorted' : null); ?>">             <a href="<?php print admin_url('admin.php?' . http_build_query(array(                 'page' => 'customer-survey-results',                 'pagination' => $page,                 'sort' => 'email',                 'dir' => $sort == 'email' ? ($dir == 'asc' ? 'desc' : 'asc') : 'asc',             ))); ?>"><span>email</span><span class="sorting-indicator">   </span></a>         </th>         <th class="customer-survey-average-label sortable <?php print $dir . ($sort == 'ipaddress' ? ' sorted' : null); ?>">             <a href="<?php print admin_url('admin.php?' . http_build_query(array(                 'page' => 'customer-survey-results',                 'pagination' => $page,                 'sort' => 'ipaddress',                 'dir' => $sort == 'ipaddress' ? ($dir == 'asc' ? 'desc' : 'asc') : 'asc',             ))); ?>"><span>ip address</span><span class="sorting-indicator"></span></a>         </th>         <th class="customer-survey-average-label sortable <?php print $dir . ($sort == 'date' ? ' sorted' : null); ?>">             <a href="<?php print admin_url('admin.php?' . http_build_query(array(                 'page' => 'customer-survey-results',                 'pagination' => $page,                 'sort' => 'date',                 'dir' => $sort == 'date' ? ($dir == 'asc' ? 'desc' : 'asc') : 'asc',             ))); ?>"><span>date submitted</span><span class="sorting-indicator"></span></a>         </th>         <th class="customer-survey-average-label">&nbsp;</th>     </tr> </thead> <tbody>     <?php foreach ($results $index => $result): ?>     <tr data-survey-trigger="<?php print $index; ?>">         <td class="customer-survey-average-value"><?php print !empty($result->customer_badge) ? $result->customer_badge : 'not given'; ?></td>         <td class="customer-survey-average-value"><?php print !empty($result->customer_email) ? $result->customer_email : 'not given'; ?></td>         <td class="customer-survey-average-value"><?php print $result->ipaddress ?></td>         <td class="customer-survey-average-value"><?php print date("m/d/y g:i a", strtotime($result->created_at)) ?></td>         <th class="customer-survey-average-label">             <a href="#">view</a>             &nbsp;&nbsp;             <button class="customer-survey-delete" type="submit" name="delete" value="<?php print $result->id; ?>">delete</button>         </th>     </tr>     <tr data-survey-target="<?php print $index; ?>">         <td colspan="5">             <div class="customer-survey-product-container">             <?php if (!empty($result->products)): ?>                 <h4>product ratings</h4>                 <ul class="customer-survey-product-ratings">                 <?php foreach ($result->products $product): ?>                     <?php if (!empty($variables['products'][$product->product])): ?>                         <li>                             <span class="customer-survey-rating-label"><?php print $variables['products'][$product->product]; ?></span>                             <span class="customer-survey-rating-value"><?php print intval($product->rating); ?></span>                         </li>                     <?php endif; ?>                 <?php endforeach; ?>                 </ul>             <?php endif; ?>              <?php if (!empty($result->product_comment)): ?>                 <h4>product comment</h4>                 <div class="customer-survey-comment"><?php print esc_textarea($result->product_comment); ?></div>             <?php endif; ?>             </div>              <div class="customer-survey-service-container">             <?php if (!empty($result->services)): ?>                 <h4>service ratings</h4>                 <ul class="customer-survey-service-ratings">                 <?php foreach ($result->services $service): ?>                     <?php if (!empty($variables['services'][$service->service])): ?>                         <li>                             <span class="customer-survey-rating-label"><?php print $variables['services'][$service->service]; ?></span>                             <span class="customer-survey-rating-value"><?php print intval($service->rating); ?></span>                         </li>                     <?php endif; ?>                 <?php endforeach; ?>                 </ul>             <?php endif; ?>              <?php if (!empty($result->service_comment)): ?>                 <h4>service comment</h4>                 <div class="customer-survey-comment"><?php print esc_textarea($result->service_comment); ?></div>             <?php endif; ?>             </div>              <div class="customer-survey-member-container">             <?php if (!empty($result->members)): ?>                 <h4>member ratings</h4>                 <ul class="customer-survey-member-ratings">                 <?php foreach ($result->members $member): ?>                     <?php if (!empty($variables['members'][$member->member])): ?>                         <li>                             <span class="customer-survey-rating-label"><?php print $variables['members'][$member->member]; ?></span>                             <span class="customer-survey-rating-value"><?php print intval($member->rating); ?></span>                         </li>                     <?php endif; ?>                 <?php endforeach; ?>                 </ul>             <?php endif; ?>              <?php if (!empty($result->member_comment)): ?>                 <h4>member comment</h4>                 <div class="customer-survey-comment"><?php print esc_textarea($result->member_comment); ?></div>             <?php endif; ?>             </div>         </td>     </tr>     <?php endforeach; ?> </tbody> 

<div class="tablenav bottom"> <div class="tablenav-pages">     <span class="displaying-num"><?php print !empty($survey_count) ? $survey_count : 0; ?> surveys</span>     <span class="pagination-links">         <a class="first-page" title="go first page" href="<?php print admin_url('admin.php?' . http_build_query(array(                 'page' => 'customer-survey-results',                 'pagination' => 1,                 'sort' => $sort,                 'dir' => $dir,             ))); ?>">«</a>         <a class="prev-page" title="go previous page" href="<?php print admin_url('admin.php?' . http_build_query(array(                 'page' => 'customer-survey-results',                 'pagination' => $page > 1 ? $page - 1 : 1,                 'sort' => $sort,                 'dir' => $dir,             ))); ?>">‹</a>         <span class="paging-input"><?php print $page; ?> of <span class="total-pages"><?php print $max_page ?></span></span>         <a class="next-page" title="go next page" href="<?php print admin_url('admin.php?' . http_build_query(array(                 'page' => 'customer-survey-results',                 'pagination' => ($page + 1) <= $max_page ? $page + 1 : $max_page,                 'sort' => $sort,                 'dir' => $dir,             ))); ?>">›</a>         <a class="last-page" title="go last page" href="<?php print admin_url('admin.php?' . http_build_query(array(                 'page' => 'customer-survey-results',                 'pagination' => $max_page,                 'sort' => $sort,                 'dir' => $dir,             ))); ?>">»</a>     </span> </div> <br class="clear"> </div>  </div> 

//the csv page

define('customer_survey_limit', 10); define('customer_survey_db', 'customer_survey'); define('customer_survey_product_db', 'customer_survey_product_rating'); define('customer_survey_service_db', 'customer_survey_service_rating'); define('customer_survey_member_db', 'customer_survey_member_rating');  $variables = customer_survey_variables();  $sql = "select * `" . customer_survey_db . "` cs 1=1;";  $results = $wpdb->get_results($sql); foreach ($results &$result) { $result->products = $wpdb->get_results($wpdb->prepare("select * `" .     customer_survey_product_db . "` customer_survey_id = %d", $result->id)); $result->services = $wpdb->get_results($wpdb->prepare("select * `" . customer_survey_service_db . "` customer_survey_id = %d", $result->id)); $result->members = $wpdb->get_results($wpdb->prepare("select * `" . customer_survey_member_db . "` customer_survey_id = %d", $result->id)); }  header('content-type: text/csv' ); header('content-disposition: attachment;filename=survey_results.csv');  $headers = array( 'badge number', 'email', 'ip address', 'date submitted', );  foreach ($variables $category => $ratings) { foreach ($ratings $key => $label) {     $headers[] = $label; } } $fp = fopen('php://output', 'w'); fputcsv($fp, $headers);  foreach ($results $index => $result) { $ratings = array(     'product' => array_fill_keys(array_keys($variables['products']), 'n/a'),     'service' => array_fill_keys(array_keys($variables['services']), 'n/a'),     'member' => array_fill_keys(array_keys($variables['members']), 'n/a'), );  $row = array(     !empty($result->customer_badge) ? $result->customer_badge : 'not given',     !empty($result->customer_email) ? $result->customer_email : 'not given',     $result->ipaddress,     date("m/d/y g:i a", strtotime($result->created_at)), );    foreach ($ratings $type => $rating) {     if (!empty($result->{$type . 's'})) {         foreach ($result->{$type . 's'} $value) {             $rating[$value->{$type}] = $value->rating;         }     }     $row += $rating;     }   fputcsv($fp, $row); } 


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -