Title: display all data
Last modified: December 26, 2016

---

# display all data

 *  Resolved Anonymous User 13716511
 * (@anonymized-13716511)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/display-all-data/)
 * I am using the ‘tablepress_table_render_data’ filter to display all the data 
   on the table.
    I’m using a query to get data from the database. However, only
   the last string of the data in the array is showing in the table. How do I get
   them all to show? Here is my code: `$args = array( ‘post_type’ => array(‘therapist_listing’,‘
   therapist’), ‘posts_per_page’ => 10 ); $loop = new WP_Query( $args ); $i = 0;
   if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();
   $i++; $field_name_type = ‘what_type_of_mental_health_professional_are_you_’; 
   $field = get_field_object($field_name_type); $value = $field[‘value’]; foreach(
   $value as $v ){ $data = $field[‘choices’][ $v ]; echo $data; //this displays 
   all the data in the field eg Clinical Social Worker, Licensed Professional Counselor,
   Certified Alcohol and Drug Abuse Counselor $table[‘data’][$i][1] = $data; // 
   this only give one value in the table eg Certified Alcohol and Drug Abuse Counselor}

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/display-all-data/#post-8591749)
 * Hi,
 * thanks for your question, and sorry for the trouble.
 * Is your `$i` variable really increasing in your code?
    Also, no matter how many
   values you would have in that “what_type_of_mental_health_professional_are_you_”
   field, it would be overwritten each time. Your loop simply is wrong for what 
   you want to do, I think.
 * Regards,
    Tobias
 *  Thread Starter Anonymous User 13716511
 * (@anonymized-13716511)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/display-all-data/#post-8594179)
 * Yes the $i is increasing as it should in the code. The loop seems to be correct,
   I’ve used it in other places just I can’t seem to store more then one value in
   the variable $table[‘data’][$i][1];
    if I echo $value all the values are shown
   so why if I set $table[‘data’][$i][1] = $value; is only one value shown?
 *  Thread Starter Anonymous User 13716511
 * (@anonymized-13716511)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/display-all-data/#post-8594272)
 * If $table[‘data’][$i][1] = $field;
    where $field is an array I get the errors:`
   Warning: substr() expects parameter 1 to be string, array given in xxx/wp-content/
   plugins/tablepress/classes/class-render.php on line 562
 * Warning: nl2br() expects parameter 1 to be string, array given in xxx/wp-content/
   plugins/tablepress/classes/class-render.php on line 766
 * if I try and loop through the array with an if($field as $fields){ $table[‘data’][
   $i][1] = $fields; } I can only get the last value in the array.
    $table[‘data’][
   $i][1] = $field[0] . $field[1] . $field[2] gives me the correct data but I need
   to loop through it, how can I do this?
 * Thank you so much for your help
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/display-all-data/#post-8594728)
 * Hi,
 * well, `$table[‘data’][$i][1]` is a string in itself, so setting
    `$table[‘data’][
   $i][1] = $value;` simply sets the string to a new one every time. What you want
   is to concatenate the existing value with the new piece. For that, you’d need
   e.g. code like `$table['data'][$i][1] = $table['data'][$i][1] . ' ' . $value;`
   or the shorter version `$table['data'][$i][1] .= ' ' . $value;`
 * Regards,
    Tobias
 *  Thread Starter Anonymous User 13716511
 * (@anonymized-13716511)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/display-all-data/#post-8594775)
 * Thank you so much for explaining that. I didn’t realise that was the case. I 
   spent hours on this.
    It is working now. Thank you for your great plugin and 
   your amazing prompt support! Really appreciated.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/display-all-data/#post-8596482)
 * Hi,
 * no problem, you are very welcome! 🙂 Good to hear that this helped!
    This is 
   the same for any other variable in PHP, nothing special. It might just be confusing
   that you are dealing with a multidimensional array here.
 * Best wishes,
    Tobias
 * P.S.: In case you haven’t, please [rate TablePress](https://wordpress.org/support/plugin/tablepress/reviews/)
   here in the plugin directory. Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘display all data’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/display-all-data/#post-8596482)
 * Status: resolved